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

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

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.

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.