Jump to content


Mysql help


1 reply to this topic

#1 nitr0x

    Young Padawan

  • Members
  • Pip
  • 201 posts

Posted 29 November 2007 - 11:03 AM

I've created a table for categories for a tutorial system, so categories can be added through the admin panel easily, but it doesn't show the name of the category but it does show the ID number in the url.

	$sql = mysql_query("SELECT * FROM `categories` ORDER BY `id` ASC");
	while( $r = mysql_fetch_object( $sql ) ){
		print '<a href="/index/category/'. $r->id .'/">'. $r->thename .'</a> ';
	}

Here's part of the source code.

<a href="/index/category/2/"></a> <a href="/index/category/3/"></a>

Any ideas? And yes, the field is called thename.

#2 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 08 December 2007 - 11:20 PM

As usual, try debugging.
Output the object $r.

var_dump($r); // Inside your loop

If it doesn't work, and the value isn't there, you can always try arrays and using mysql_fetch_array(). If that still doesn't yield correctly, then there must be something wrong with the query not getting the data correctly (such as all the columns being blank).





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users