cygnusonline Posted October 18, 2010 Share Posted October 18, 2010 Hi I have a problem that I must admit I have come across before but I can't remember the fix. When I do a simple select query then print it out using a while statement, I can't get it to print out the first record of my results. I am sure this is to do with the execute statement but I can't get it to work properly. I currently have test data in so I know this should bring out 6 records but it only lists 5 Quote Link to comment https://forums.phpfreaks.com/topic/216166-php-not-printing-first-record-from-a-query/ Share on other sites More sharing options...
litebearer Posted October 18, 2010 Share Posted October 18, 2010 just a little restructuring. perhaps... $querycaseworker = "(SELECT * FROM tracker.client WHERE tracker.client.caseRef = '$caseRef ' ORDER BY clientLastname, clientFirstname)"; // Execute the query $resultcaseworker = mysql_query($querycaseworker, $link_id); $count = mysql_num_rows($resultcaseworker); echo "<table>"; while ($record = mysql_fetch_array($resultcaseworker)) { $fullname = $record['clientFirstname'] . " " . $record['clientLastname']; $caseref=$record['caseRef']; <tr> <td><a href="record.php?caseref=<?PHP echo $caseref; ?>"><?PHP echo $caseref; ?></a></td> <td><?PHP echo $fullname; ?></td> </tr> <?PHP } echo "<table>"; Quote Link to comment https://forums.phpfreaks.com/topic/216166-php-not-printing-first-record-from-a-query/#findComment-1123444 Share on other sites More sharing options...
cygnusonline Posted October 18, 2010 Author Share Posted October 18, 2010 Thanks for that, I don't know exactly were the error was but it is working now!! Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/216166-php-not-printing-first-record-from-a-query/#findComment-1123445 Share on other sites More sharing options...
PFMaBiSmAd Posted October 18, 2010 Share Posted October 18, 2010 It's highly likely that the code you posted/removed in the first post was NOT the actual code that exhibited the problem. Your actual code was likely fetching, but not using, the first row of data, in between your query statement and the start of the while() loop. Quote Link to comment https://forums.phpfreaks.com/topic/216166-php-not-printing-first-record-from-a-query/#findComment-1123462 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.