Re: PHP output fails from AJAX call

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Below is my ajaxex.php :-

[root@]# cat ajaxex.php
<?php

$q = intval($_GET['q']);

$con=mysqli_connect("db11.app.com","root","123","ots")
;

if (!$con)
  {
  die('Could not connect: ' . mysqli_error($con));
  }

$result = mysqli_query($con,"SELECT  us.login user,WEEK(cw.create_time,
'%Y-%m') AS WEEK,min(cw.create_time) ws ,max(cw.create_time) we,COUNT(*) AS
total_cr  FROM
 change_item cw,users us  where cw.create_time < now() and cw.create_by=
us.id and cw.create_by = '".$q."'  GROUP BY  1,2");

        //Build Result String
echo "<table border='1'>
<tr>
<th>user</th>
<th>WEEK</th>
<th>ws</th>
<th>we</th>
<th>total_cr</th>
</tr>";

while($row = mysqli_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['user'] . "</td>";
  echo "<td>" . $row['WEEK'] . "</td>";
  echo "<td>" . $row['ws'] . "</td>";
  echo "<td>" . $row['we'] . "</td>";
  echo "<td>" . $row['total_cr'] . "</td>";
  echo "</tr>";
  }

echo "</table>";

?>

Thanks



On Thu, Jan 30, 2014 at 3:12 PM, Tim Streater <tim@xxxxxxxxxxxxxxxx> wrote:

> On 30 Jan 2014 at 06:27, Adarsh Sharma <eddy.adarsh@xxxxxxxxx> wrote:
>
> > Hi,
> >
> > I am using AJAX and php for creating a small UI that retrieves data from
> > mysql upon clicking on one button. But i clicked on that , nothing is
> > happening. Below is my index.html :
> >
> > *-- index.html *
> >
> > <html>
> > <head>
>
> Missing <script ... > as Niklaus has pointed out.
>
> > function week_report_fun(){
> > var ajaxRequest;
> > ---
> > ---
> > --
> > ajaxRequest.open("GET","ajaxex.php?q="+users,true);
>
> What is "users"? Where is your code to get the selected value from the
> form?
>
> > ajaxRequest.send();
> > }
> >
> > </script></head><body>
> > <form>
> > User : <select id="users" onchange="week_report_fun()">
> > <option value="">Select a user</option>
> > <option value="133">av</option>
> > <option value="168">ad</option>
> > <option value="78">so</option>
> > <option value="239">ak</option>
> > </select></form><br>
> > <div id="txtHint"><b>Person info will be listed here.</b></div>
> > </body></html>
>
> Where is your code to get the returned results from your PHP script and
> display it?
>
>
> --
> Cheers  --  Tim
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux