First
query page display all results <?php //The
database has been connected to, and we have a query result. $result = mysql_query("select
* from table"); $num_rows = mysql_num_rows($result); if ($myrow
= mysql_fetch_array($result)) { $thumb='<img src=http://your_website/thumbs/'; $web='http://www.yourwebsite/detail.php?name=';
$f='<font
face=verdana,arial size=2'; $s='<span style=padding-left:3px';
echo
"<table border=0>\n"; echo "<tr><td></td><td></td><td></td><td></td></tr>\n"; do
{ //present
lots of references and a link to detail.php?name=[reference]
printf("<tr><td><a
href=$web%s>$thumb%s.jpg></a></td><td><a href=$web%s>$s>$f>%s</font></span></a></td><td>$s>$f>%s</font></span></td><td>$s>$f>%s</font></span></td>
</tr>\n", $myrow["reference"], $myrow["thumb"],
$myrow["reference"], $myrow["shortdescription"], $myrow["suburb"],
$myrow["price"]); } while ($myrow = mysql_fetch_array($result));
echo "</table>\n"; echo "<br>"; }
else { echo "Sorry, no records available"; }
detail.php <?php $ref="$name"; if
(empty($ref)) { echo "Oops, the reference has been terminated with extreme
prejudice"; exit; } echo "<font face=verdana,arial,helvetica
size=2>Information for:<i><b> $name</i></b></font>"; ?> //
after doing database connection
$more
= mysql_query("SELECT * FROM table WHERE reference='$ref'",$db); $num_rows
= mysql_num_rows($more);
$i=0; while ($i < $num_rows) { $m=mysql_result($more,$i,"shortdescription"); $v=mysql_result($more,$i,"description"); $h=mysql_result($more,$i,"suburb"); $t=mysql_result($more,$i,"text2"); $r=mysql_result($more,$i,"rooms"); $b=mysql_result($more,$i,"bathrooms"); $e=mysql_result($more,$i,"ensuites"); $l=mysql_result($more,$i,"land"); $p=mysql_result($more,$i,"price"); $c=mysql_result($more,$i,"consultant"); $img1=mysql_result($more,$i,"image1"); $img2=mysql_result($more,$i,"image2"); $img3=mysql_result($more,$i,"image3"); ++$i; } //
display results for this reference as you see fit //set
up the "next" link
$i=0;
//
loop through the results while ($i < $num_rows) { $next=mysql_result($result2,$i,"reference"); $i++; //and
store as an array $myarray = array("$i"=>"$next"); //look
in array for the current reference and return the key foreach($myarray as
$key=>$value) { if ($value == "$ref"){ $b=($key); //increment
the key by 1 $c=($b+1); }} //if
greater than all records notify if ($num_rows < $c) { echo "Records
End"; } else { //
retrieve value for the row and come back to this page with the new reference if
($key == "$c") echo "<font face=verdana,arial,helvetica size=1
color=#898A89><a href=detail.php?name=$value>Next Listing</a></font><br>"; }
} }
else { echo "Sorry, no records were found"; } ?> |