Hi I am trying to write a script that puts a Horizontal Line between MySQL query results but doesn't show up after the last row.

eg:

First Line
----------------
Second Line
----------------
Third Line

I'm using PHP, MySQL and JavaScript AJAX. Don't know if that's relevant for this instance or not.

Any help would be appreciated.

I think what you want to do is something a long the lines of this;

$result = mysql_query("select * from table");
$counter = 0;
$rowcount = mysql_num_rows($result);
while($row=mysql_fetch_array($result)) { 
  echo "process row data";  
  if ($count < $rowcount) {
    echo "<hr />";
  }
  $counter++
}

Hope that helps.

Here's an example:

$res = mysql_query("SELECT * FROM `table`");
$count = 0;
$num = mysql_num_rows($res);
while ($r = mysql_fetch_array($res))
	{
	$count++;
	// echo some data:
	echo $r['something'];
	if ($count < $num)
		{
		echo "<hr/>";
		}
	}

Thanks, everyone. I was actually able to figure it out :P. Umm here's my code I think it's similar to the examples I received.

$rowcount = 1;

if ( mysqli_num_rows($result) == $rowcount){
	echo "Last Row";
} else {
        echo "Rows" .
        "<hr style='color:#00FF00;' />";
        $rowcount = $rowcount + 1;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.