Re: [PHP] Catagory list

2001-03-31 Thread Joe Stump
This is what I'd do: $sql = "SELECT disinct category FROM article ORDER BY category"; $r = mysql_query($sql); while($cat = mysql_fetch_array($r)) { $id = $cat['id']; $sql = "SELECT * FROM article WHERE category='$id'"; $x = mysql_query($sql); while($row =

[PHP] Catagory list

2001-03-30 Thread Mark Bayfield
I am trying to make a catagory list that displays a distinct catagory, and then listing titles under that catagory. Unfortunatly all the data is in one table, and the catagory field is not set catagories, so there is duplicates in that field. The code so far is (but I am probably going about it

Re: [PHP] Catagory list

2001-03-30 Thread elias
please try this: - I didn't really get what you mean, but i can see that you have a table such: Table fields: category, fieldx, fieldy, fieldz, title and you want to display it's data as: category 1 title1 (belonging to cat1) title2 (...) title3 () title4 (...) cat2 titlex

Re: [PHP] Catagory list

2001-03-30 Thread Mark Bayfield
Thanks for the code. Its not doing exactly what I want, but with a little modification is is kind of working. The one problem is that it is putting the Title first and the catagory second. so it is coming up with: title1 title2 catagory title3 title4 catagory1 and the last catagory is droping

Re: [PHP] Catagory list

2001-03-30 Thread Mark Bayfield
Thanks for the code... I got it to do what I wanted, by modifying it to this $result = mysql_query ("SELECT * from article ORDER BY catagory"); $temp = ""; while ($r = mysql_fetch_array($result)) { if (empty($temp)) // will be fired only once! { $temp = $r["catagory"]; // get

Re: [PHP] Catagory list

2001-03-30 Thread Basil Groman
If I understand what you are looking for, this should work for you: $indent_str = 'nbsp;nbsp;nbsp;'; $qry = 'SELECT * FROM test ORDER BY category'; $result = mysql_query($qry); $current_category = ""; while ($r = mysql_fetch_array($result)){ if ($r['category'] $current_category){

Re: [PHP] Catagory list

2001-03-30 Thread Mark Bayfield
Thanks man, this works great... "Basil Groman" [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... If I understand what you are looking for, this should work for you: $indent_str = 'nbsp;nbsp;nbsp;'; $qry = 'SELECT * FROM test ORDER BY category'; $result =