|
Posted by ClickToWalk on 10/02/41 11:53
I have created some next & previous navigation links on a form I am using to
administer a particular database I am working with.
The navigation links are just hyper links where, on each click, the value of
id is either incremented or decremented. The id is then taken from the url
using
$_GET['id'] to create/ammend the variable $id which is then passed to an
included file to retreive all table records relating to that id.
This all worked fine while record id's in the table were consecutive, but
I've since deleted some records and now in some cases empty records are
returned.
I've been over and over the manual but have been unable to find a solution,
have tried taking other snippets of code which appear to be similar to what
I am trying to achieve but with no success. I guess I'm missing something
pretty fundamental here.
This is a bit of code that I have used to successfully echo all the
available records - with gaps where records are missing - but what
modifications do I need to make to it so that only one row is returned from
the recordset, determined by $id.
$query=sprintf("SELECT locl_id FROM tbl_locl");
$result = mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $result;
die($message);
}
while ($row = mysql_fetch_array($result))
{
echo $row['locl_id']."<br>";
}
Thanks in advance
Matt
"I'm an idealist. I don't know where I'm going, but I'm on my way." - Carl
Sandburg http://clicktowalk.com Page design © Matthew McCabe -
http://mattmadethis.com Site hosted by Xeriom Networks -
http://xeriom.net/in/1019
Navigation:
[Reply to this message]
|