Jump to content

Query only returns one results when phpmyadmin gives me 14


Darkmatter5

Recommended Posts

Here's my query

 

$query="SELECT jobs.job_number, clients.full_name, jobs.job_desc
  FROM jobs
  LEFT JOIN clients ON jobs.client_id=clients.client_id
  WHERE jobs.job_number LIKE '$_POST[searchtext]%'
  ORDER BY jobs.job_number ASC";

 

Here's the other code

 

$result=mysql_query($query);
$row=mysql_fetch_array($result);
$count=mysql_num_rows($result);
if($count<1) { echo "No results from search found!"; }
else {
  echo "<ol>";
  foreach($row as $res) {
    echo "<li>$row[job_number] - $row[full_name] - $row[job_desc]</li>";
  }
  echo "</ol>";
}

 

It only outputs the first result and it does it three times, not the 14.  What's going on??

Try this....

<?php

$result=mysql_query($query);
$count=mysql_num_rows($result);

echo 'There are '. $count .' rows in the result<br />';
if($count<1) { echo "No results from search found!"; }
else {
  echo "<ol>";
  while($row = mysq_fetch_array($result)) {
    echo '<li>'.$row['job_number'].' - '.$row['full_name'].' - '.$row['job_desc'].'</li>';
  }
  echo "</ol>";
}

?>

 

See if that gets you the results you expect. I added the line of "there are XX number of results".... to show what the query returned.

 

nate

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.