Jump to content

[SOLVED] not getting all results


cs1h

Recommended Posts

Hi,

 

I have a script that is meant to get and show all the relevant results from a table, but it's only showing one result.

 

The script is,

 

<?php

$art = $_GET['id'];

mysql_connect("localhost","xxx","xxx"); 

mysql_select_db("xxx") or die("Unable to select database");

$sql = "SELECT * FROM xxx WHERE yyy ='$art' ORDER BY lastpost DESC";

$result = mysql_query($sql);
$num_rows = mysql_num_rows($result);
if($num_rows == 0) {
echo "no results";
} else {
while($row = mysql_fetch_array($result)) {
$title = $row['name'];
$date = $row['started'];
$started_date = date_create ($date);
$started_year = date_format ($started_date, 'dS F Y');
$started_hour = date_format ($started_date, 'G:ia');
$last_post_date = $row['lastpost'];
$last_date = date_create ($last_post_date);
$last_year = date_format ($last_date, 'dS F Y');
$last_hour = date_format ($last_date, 'G:ia');
$views = $row['views'];
$replies = $row['replies'];
$author = $row['author'];
$last_author = $row['last_author'];

}
echo "<div>
  <div id=\"topic_box\">
    <div class=\"topic_left\"><span class=\"blue_large\">$title</span></div>
 <div class=\"topic_right\"><span class=\"grey_small\">$replies reply, $views views</span></div>
     <div class=\"topic_info\"><span class=\"grey_small\">posted  $started_year at $started_hour by</span> <span class=\"blue_small\">$author</span></div>

<div class=\"topic_info\"><span class=\"grey_small\">last reply $last_year at $last_hour by</span> <span class=\"blue_small\">$last_author</span></div>

</div></div>";
}

?>

 

Does anyone know why this is?

There is plenty of results in the table, it's just not showing them.

 

Thanks,

Colin

Link to comment
https://forums.phpfreaks.com/topic/124945-solved-not-getting-all-results/
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.