Help with this code...
Posted: Wed Dec 01, 2004 1:50 pm
hi i have this code
and i want those links redirect me to certain book title, this my next code
The reason i put comments there, its because when i put that code, its worked tho, but it can't retrive the first record, but for 2nd until end of records are displayed.
Question are:
1. How can i display a "NULL" value?? i mean if i do query and i get NULL value and i want to display, lets say i want to display "No Book Title Fund!"
2. And for the link show.php?title=0 i want it link to my records which is bookTitle that has 0 (zero) in it, how do i do that??
thnx...
Code: Select all
<?php
// Lists the letters of the alphabet with
// links associated with each letter
print "\t\t<a href="?alpha=0" class="alphalink">0-9</a>\n";
for($i=65;$i<=90;$i++){
$x = chr($i);
$alphalink = "?alpha=".$x;
print "\t\t\t<a href="$alphalink" class="alphalink">$x</a>\n";
}
?>Code: Select all
<?php
if($_GET["alpha"]){
db_connect(); // This is function that i made for connecting to db server
$id = $HTTP_GET_VARS["alpha"];
$query = "SELECT PK_bookID,bookTitle,yearPublished,pages,ISBN FROM tbl_book WHERE bookTitle LIKE '$id%' GROUP BY bookTitle";
$result = mysql_query($query) or die(mysql_error());
// if(!mysql_fetch_row($result)){
// print "<td><font size="-1" color="grey"><i>no title found!</i></font>";
// print "<td><font size="-1" color="grey"><i>n/a</i></font>";
// print "<td><font size="-1" color="grey"><i>n/a</i></font>";
// print "<td><font size="-1" color="grey"><i>n/a</i></font>";
// exit;
// }
while ($alpha_rows = mysql_fetch_array($result)){
?>
<tr>
<td><a href="show.php?title=<? echo "$alpha_rows[0]"; ?><? echo "$book_rows[0]"?>"><? echo "$alpha_rows[1]"; ?></a></td>
<td><? echo "$alpha_rows[2]"; ?></td>
<td><? echo "$alpha_rows[3]"; ?></td>
<td><? echo "$alpha_rows[4]"; ?></td>
</tr>
<?
}
}
?>Question are:
1. How can i display a "NULL" value?? i mean if i do query and i get NULL value and i want to display, lets say i want to display "No Book Title Fund!"
2. And for the link show.php?title=0 i want it link to my records which is bookTitle that has 0 (zero) in it, how do i do that??
thnx...