Ajax/MySQL problems
I have a page that lists industries using horizontal looper.
That works fine.
Now my customer has decided that he wants to cut down on the text on the page by having a list from A-Z at the top from where a user can select.
So I decided I did not want a page refresh so I looked @ http://www.w3schools.com/PHP/php_ajax_database.asp
I have modified the code to my needs, but the sql keeps falling down and give me this message: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in
I also get Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in
I do not know what to do.
Can some one help me?
-- html page --
<a href="#" onclick="showUser(this.value)">A</a> B C
<div id="txtHint"><b>Person info will be listed here.</b></div>
-- php page --
<?php
$q=$_GET["q"];
$con = mysql_connect('localhost', 'demo', 'demo');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("demo", $con);
$sql="SELECT * FROM industry WHERE industry LIKE %'".$q."' ORDER BY industry ASC";
$sql_endRow = 0;
$sql_columns = 6; // number of columns
$sql_hloopRow1 = 0; // first row flag
do {
if($sql_endRow == 0 && $sql_hloopRow1++ != 0) echo "<tr>";
?>
<td><div id="bdTagLinks"><a href="search_by_industry.php?id=<?php echo $row_sql['ind_id']; ?>"><?php echo $row_sql['industry']; ?></a></div></td>
<?php $sql_endRow++;
if($sql_endRow >= $sql_columns) {
?>
</tr>
<?php
$sql_endRow = 0;
}
} while ($row_sql = mysql_fetch_array($result));
if($sql_endRow != 0) {
while ($sql_endRow < $sql_columns) {
echo("<td> </td>");
$sql_endRow++;
}
echo("</tr>");
}
mysql_close($con);
?>
The JS page has not changed apart from the php pages name.