Jump to content

PHP not printing first record from a query


cygnusonline

Recommended Posts

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

Link to comment
Share on other sites

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>";

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.