3 Replies - 614 Views - Last Post: 27 March 2013 - 11:50 AM Rate Topic: -----

#1 DkSnowdon  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 128
  • Joined: 31-October 12

echoing multiple rows from a database

Posted 26 March 2013 - 03:04 AM


// get categorys names
$sql_cat_name = "SELECT name,order FROM category ORDER BY order";
$result_cat_name = mysqli_query($con,$sql_cat_name);

while($row_cat_name = mysqli_fetch_array($result_cat_name))
{
	// echo the category main part
	echo '<li '.$category[$row_cat_name["order"]].' ><a class="set" href="index.php?id='.$category[$row_cat_name["order"]].'>'.$result_cat_name["name"].'</a>';
	
	echo '<ul>';
	
	// echo each row in the category
	
	echo '</ul></li>';
}



for some reason this does not work for multiple rows can anyone help me

This post has been edited by Dormilich: 26 March 2013 - 03:05 AM


Is This A Good Question/Topic? 0
  • +

Replies To: echoing multiple rows from a database

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,251
  • Joined: 08-June 10

Re: echoing multiple rows from a database

Posted 26 March 2013 - 03:13 AM

where does the variable $category come from?

and if you loop, then you only have the values $row_cat_name["order"] and $row_cat_name["name"] (not($result_cat_name["name"])) available.
Was This Post Helpful? 0
  • +
  • -

#3 DkSnowdon  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 128
  • Joined: 31-October 12

Re: echoing multiple rows from a database

Posted 27 March 2013 - 11:43 AM

the category variable works i know that, i forgot to include the code.
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3517
  • View blog
  • Posts: 12,008
  • Joined: 12-December 12

Re: echoing multiple rows from a database

Posted 27 March 2013 - 11:50 AM

ORDER BY order

Does there not seem something wrong with this statement?! order is a reserved word so you should preferably rename this field or (in MySql) surround both occurrences with back-ticks `.

If you turn on all error reporting you should receive at least one error for this.

error_reporting(E_ALL);
ini_set('display_errors', '1');

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1