I'll appologize in advance, because I really don't know what I'm doing. I just started learning all of this a few days ago. The webpage I'm working with can be viewed here:
Instead of one long column, I'm trying to get this set up into two. I know how to do it, but not with the array. Here's my code:
I'm getting this error:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/neodaze/public_html/booklist2.php on line 29
Line 29 is this:
$numofrows = mysql_num_rows($result);
I'd greatly appreciate it if anyone can tell me what I'm doing wrong. Thanks!
Instead of one long column, I'm trying to get this set up into two. I know how to do it, but not with the array. Here's my code:
Code:
<?php
include("connect.php");
mysql_connect($host, $user, $password);
mysql_select_db($database);
$var = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z");
echo "<table align=center><tr>";
echo "<td><font size=+1><b><a href=booklist.php>#</a></b></font></td>";
foreach($var as $value)
{
echo "<td align=center><font size=+1><b><a href=\"{$_SERVER['PHP_SELF']}?list={$value}\">{$value}</a></b></font></td>";
}
echo "</tr></table><br>";
if (isset($_GET["list"]))
{
$query = mysql_query("SELECT * FROM `books` WHERE `title` LIKE '{$_GET['list']}%' ORDER BY `title`");
}else{
$query = mysql_query("SELECT * FROM `books` WHERE (`title` LIKE '0%') OR (`title` LIKE '1%') OR (`title` LIKE '2%') OR (`title` LIKE '3%') OR (`title` LIKE '4%') OR (`title` LIKE '5%') OR (`title` LIKE '6%') OR (`title` LIKE '7%') OR (`title` LIKE '8%') OR (`title` LIKE '9%') ORDER BY `title`");
}
while($r=mysql_fetch_array($query));
$numofrows = mysql_num_rows($result);
?>
<?php
echo "<table align=center width=700><tr><td>\n";
for($i = 0; $i < $numofrows; $i++) {
$row = mysql_fetch_array($result);
if($i % 2) {
echo "</TD><TD valign=top><BR><table align=center cellpadding=4 cellspacing=4>\n";
} else {
echo "</TD></TR><TR><TD valign=top><BR><table align=center cellpadding=4 cellspacing=4>\n";
}
extract($r);
echo "<TR><td align=center bgcolor=#FFFFCE width=80><font size=-1>".$row['rarity']."</font></TD>\n";
echo "<td align=center bgcolor=#FFFFCE width=200><b>".$row['title']."</b></TD></TR>\n";
echo "<TR><td align=center bgcolor=#4A8CCE width=80>".$row['image']."</TD>\n";
echo "<td valign=center width=200><font size=-1>".$row['info']."</font></TD></TR>\n";
echo "</TABLE>\n";
}
echo "</td></tr></table>\n";
?>
I'm getting this error:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/neodaze/public_html/booklist2.php on line 29
Line 29 is this:
$numofrows = mysql_num_rows($result);
I'd greatly appreciate it if anyone can tell me what I'm doing wrong. Thanks!