
January 29th, 2003, 09:02 AM
|
|
Junior Member
|
|
Join Date: Jan 2003
Location: Ireland
Posts: 11
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
On/off working code :(
This is the code
PHP Code:
<?
srand((double)microtime()*1000000);
$conn = mysql_connect("localhost","uname","pword") or die("Unable to connect to database");
$db = mysql_select_db("irelandbnb") or die("Unable to select database irelandbnb");
if($town=="all") $query = 'select * from data where `county`="'.$county.'"';
else $query = 'select * from data where `county` = "'.$county.'" and `town` = "'.$town.'"';
$result = mysql_query($query);
$max = mysql_num_rows($result);
if(!isset($seed)){
$seed = rand(1, $max);
$i = $seed;
$j = 0;
$page = 1;
}
else {
$i = $last;
$j = 0;
}
//To fill town select box
$query1 = "select * from data where `county`=\"".$county."\"";
$result1 = mysql_query($query1);
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Ireland bed and breakfast</title><link rel="stylesheet" type="text/css" href="style/ibnb.css">
</head>
<body>
<div align="center"><img src="graphics/top.gif" alt="Ireland Bed and Breakfast" width="750" height="92" border="0"><br>
<table align="center" width="750" cellspacing="0" cellpadding="0" border="0">
<tr align="center" bgcolor="#0080c0">
<td><a title="Home" href="index.html" class="menu">Home</a></td>
<td><a href="glossary.html" class="menu" title="Glossary of Terms">Glossary</a></td>
<td><a class="menu" title="Car Rental Ireland" href="http://www.irish-car-rental.com" target="_blank">Car Rental</a></td>
<td><a class="menu" title="Membership details" href="membership.html" target="_blank">Membership</a></td>
<td><a class="menu" title="About us" href="about.html">About Us</a></td>
<td><a title="Tourism and Leisure in Ireland" href="http://www.insightwebmarketing.com" target="_blank" class="menu">Insight Network</a></td>
</tr>
</table>
<table align="center" width="750" cellspacing="0" cellpadding="15" border="0" bgcolor="#ffffff" style="padding-top: 10px;">
<tr>
<td align="center" width="600" valign="height" class="ban"><a href="properties.html">
<sxcript language="JavaScript" src="http://www.insight-intermark.com/banad/ads.pl?jscript" type="text/javascript"></script>
</td>
<td rowspan="3" valign="middle" width="150">
<a href="html/index.html"><img src="graphics/space.gif" alt="Dublin Accommodation Ireland" width="125" height="1" border="0"></a><br>
<sxcript language="JavaScript" src="http://www.insight-intermark.com/buttons/ads.pl?jscript">
</script><br><br>
<sxcript language="JavaScript" src="http://www.insight-intermark.com/buttons/ads.pl?jscript"></script><br><br>
<sxcript language="JavaScript" src="http://www.insight-intermark.com/buttons/ads.pl?jscript"></script><br><br>
<sxcript language="JavaScript" src="http://www.insight-intermark.com/buttons/ads.pl?jscript"></script><br><br>
<sxcript language="JavaScript" src="http://www.insight-intermark.com/buttons/ads.pl?jscript"></script><br><br></td>
</td>
</tr>
<tr>
<td align="center" width="512" valign="middle" class="ban">
<?php
echo '<form name=select action="list.html" style="margin-bottom: -3px">';
echo '<input type="hidden" name="county" value="'.$county.'">';
echo '<select name="town" style="width: 400px;color:red;" onchange="document.select.submit()">';
echo '<option> Search Another Town Here';
$towns = array("");
while ($myrow = mysql_fetch_row($result1)) {
if(!in_array($myrow[2], $towns)) {
$x = end($towns);
$towns[$x] = $myrow[2];
echo "<option>".$myrow[2]; }
}
?>
</select></form>
</td></tr>
<tr>
<td>
<table align="center" cellspacing="0" cellpadding="6" border="0" width="100%" class="head"><tr>
<?
if(($page*10)<=$max) echo '<th align="left">You are viewing properties '.(($page*10)-9).' - '.($page*10).' of '.$max.'.</th>';
else echo '<th align="left">You are viewing properties '.(($page*10)-9).' - '.$max.' of '.$max.'.</th>';
if($page>1) {
echo '<th align="left"><a href="'.$PHP_SELF.'?page='.($page-1).'&county='.$county.'&town='.$town.'&seed='.$seed;
$a = $i-10;
if($a < 0){
$a = $max+$a;
echo '&last='.$a.'" class="head"><- Previous</a></th>';
}
else echo '&last='.$a.'" class="head"><- Previous</a></th>';
}
if($page<($max/10)) {
echo '<th align="right"> <a href="'.$PHP_SELF.'?page='.($page+1).'&county='.$county.'&town='.$town.'&seed='.$seed;
$a = $i+10;
if($a > $max){
$a = $a-$max;
echo '&last='.$a.'" class="head">Next -></a></th>';
}
else '&last='.$a.'" class="head">Next -></a></th>';
}
echo '</tr></table>';
//-----------------------------------
echo '<table align="center" cellspacing="0" cellpadding="6" border="0" width="100%" class="thbs"><tr>';
do {
if($i == $max+1) $i = 1;
if($town == "all") $query = 'select * from data where `id`="'.$i.'" and `county`="'.$county.'"';
else $query = 'select * from data where `id`="'.$i.'" and `county`="'.$county.'" and `town`="'.$town.'"';
$res = mysql_query($query);
$row = mysql_fetch_row($res);
echo "
<td rowspan='2' width='100' class='small' align='center'>
<a href='display.html?id=$row[19]'>
<img src='thumbs/$row[10]' alt='Click for further details' width='100' height='66' border='0'>
<br>Further details here</a></td>
<td class='thbs2' width='320'>$row[18], $row[2]</td>
<td rowspan='2' width='38' valign='middle' class='thbs3'>
<a href='display.html?id=$row[19]'>
<img src='graphics/moreinfo.gif' width='36' height='36' alt='Click here for further details' border='0'></a></td>
</tr><tr>
<td class='small'>
<img src='graphics/space.gif' alt='' width='1' height='56' border='0' align='right'>$row[9]</td>
</tr>";
$i++;
$j++;
} while(($j < 10) && ($i != $seed));
$j = 0;
$page++;
echo '</table>';
?>
</td>
</tr>
</table>
<table width="750" align="center" border="0" cellspacing="0">
<tr>
<td class="hf" width="24">
<a href="mailto:michael"insightwebmarketing.com"> <img src="graphics/email.gif" alt="Email Us" width="14" height="10" hspace="10" border="0"></a>
</td>
<td class="hf">
<a href="http://www.insightwebmarketing.com" class="hf" title="Click for Ireland\'s Internet Marketing Agency for Tourism & Leisure">
Copyright © 1995 - <script language=JavaScript>var today=new Date();
var year=today.getFullYear();
document.write(year);</script> - Insight Web Marketing Ltd - Killarney</a>
</td>
<td class="hf" width="24">
<a href="aboutus.html"><img src="graphics/info.gif" alt="About Insight Web Marketing" width="14" height="14" hspace="10" border="0"></a>
</td>
</tr>
</table>
</body>
</html>
Now what its meant to do:
It picks a random number ($seed) between 1 and the last record in the query. It then displays 10 records per page until all the records that fit in the query have been shown.
It worked for a little while except that my previous and next buttons weren't working. So I fixed that and since then I have had the following two problems:
1) Records 14 and 16 are never displayed :roll: even though they are deffinetly present in the database, and they were always shown before....
2) The random sort works fine for one $town but for the rest it just displays blank cells.....
Help Please!!!
|