Jump to content

Php / Mysql select issue


Prank

Recommended Posts

Hi Guys,

I have a table with 5 records in it, when I select the records (even just using SELECT * FROM cars) it will sometimes retrieve 3 records and sometimes 4, never the whole amount. I have never seen this happen before. If I run the query in phpmyadmin it returns all records. I dont understand how this could happen, the Statement could not be more simple.

Anyone know why this could be happening?

Christian
Link to comment
https://forums.phpfreaks.com/topic/19094-php-mysql-select-issue/
Share on other sites

Its happening in several places, each with re-written code.

The code couldnt be more simple.

Heres one example;
[code]
        $q = "SELECT * FROM cars";
$qr = mysql_query($q) or die(mysql_error());
$r = mysql_fetch_assoc($qr);

echo '<strong>Select a link category</strong><br />';

while($r = mysql_fetch_assoc($qr)){

echo '<a href="links.php?do=listlinks&cat='.$r['name'].'">'.$r['name'].'</a><br />';

} // while[/code]

Thanks.
Link to comment
https://forums.phpfreaks.com/topic/19094-php-mysql-select-issue/#findComment-82626
Share on other sites

[code]<?php
        $q = "SELECT * FROM cars";
$qr = mysql_query($q) or die(mysql_error());
$r = mysql_fetch_assoc($qr); // <- You already get one row here

echo '<strong>Select a link category</strong><br />';

while($r = mysql_fetch_assoc($qr)){
        // and ofcourse overhere total loops will be minus one of total rows
echo '<a href="links.php?do=listlinks&cat='.$r['name'].'">'.$r['name'].'</a><br />';

} // while
?>[/code]
Link to comment
https://forums.phpfreaks.com/topic/19094-php-mysql-select-issue/#findComment-82628
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.