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 = mysql_fetch_array($x))
{
  // echo articles here
}
  }

The permanent solution is to make a separate table called "categories" and then
do a join on the categoryID from the two tables.

--Joe

On Fri, Mar 30, 2001 at 10:33:11PM +1000, Mark Bayfield wrote:
 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 the wrong way, if you
 can see whats wrong with my code plase help, or point me in some direction),
 
  $query = mysql_query("SELECT DISTINCT catagory from article order by
 catagory");
  $query2 = mysql_query ("SELECT * from article ORDER BY catagory");
 
  for ($index = 0; $index  mysql_num_rows($query); $index++) {
   $Catagory = mysql_fetch_row ($query) or die (mysql_error());
   $name1 =  mysql_fetch_row ($query2) or die (mysql_error());
   $x = $name1;
   $result1 = array_unique($Catagory);
   $result = array_merge($Catagory, $name1);
 
print ("$result1[0]BR");
for ($x=0; $x == $result1[0]; $x++) {
print ("nbsp;nbsp;nbsp;nbsp;a
 href='update.php?passed=$name1[0]'$name1[2]/abr\n");
}
  }
 
 I am trying everything to get it do just print the following:
 
 Catagory
 title1
 title2
 Catagory1
 title3
 title4
 
 Please help me out
 
 thanks
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]


/**\
 *Joe Stump - PHP/SQL/HTML Developer  *
 * http://www.care2.com - http://www.miester.org - http://gtk.php-coder.net   *
 * "Better to double your money on mediocrity than lose it all on a dream."   * 
\**/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[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 the wrong way, if you
can see whats wrong with my code plase help, or point me in some direction),

 $query = mysql_query("SELECT DISTINCT catagory from article order by
catagory");
 $query2 = mysql_query ("SELECT * from article ORDER BY catagory");

 for ($index = 0; $index  mysql_num_rows($query); $index++) {
  $Catagory = mysql_fetch_row ($query) or die (mysql_error());
  $name1 =  mysql_fetch_row ($query2) or die (mysql_error());
  $x = $name1;
  $result1 = array_unique($Catagory);
  $result = array_merge($Catagory, $name1);

   print ("$result1[0]BR");
   for ($x=0; $x == $result1[0]; $x++) {
   print ("nbsp;nbsp;nbsp;nbsp;a
href='update.php?passed=$name1[0]'$name1[2]/abr\n");
   }
 }

I am trying everything to get it do just print the following:

Catagory
title1
title2
Catagory1
title3
title4

Please help me out

thanks



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




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
   titley
   titlez

that what you said, right?
okay, try 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["category"]; // get category name
echo "This is category $temp, and it's titles are as following:br"; //
display it
  }

  if ($temp != $r["category"]) // because it's sorted by category, this
method will work!
echo "This is category $temp, and it's titles are as following:br"; //
display it
  // update last category name
  $temp = $r["category"];
  echo "this is title " . $r["title"] . "br";

}
**
-
""Mark Bayfield"" [EMAIL PROTECTED] wrote in message
9a1u3q$k81$[EMAIL PROTECTED]">news:9a1u3q$k81$[EMAIL PROTECTED]...
 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 the wrong way, if you
 can see whats wrong with my code plase help, or point me in some
direction),

  $query = mysql_query("SELECT DISTINCT catagory from article order by
 catagory");
  $query2 = mysql_query ("SELECT * from article ORDER BY catagory");

  for ($index = 0; $index  mysql_num_rows($query); $index++) {
   $Catagory = mysql_fetch_row ($query) or die (mysql_error());
   $name1 =  mysql_fetch_row ($query2) or die (mysql_error());
   $x = $name1;
   $result1 = array_unique($Catagory);
   $result = array_merge($Catagory, $name1);

print ("$result1[0]BR");
for ($x=0; $x == $result1[0]; $x++) {
print ("nbsp;nbsp;nbsp;nbsp;a
 href='update.php?passed=$name1[0]'$name1[2]/abr\n");
}
  }

 I am trying everything to get it do just print the following:

 Catagory
 title1
 title2
 Catagory1
 title3
 title4

 Please help me out

 thanks



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




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 off. I have modified the code as such (if
you can help so that the catagory is first and the titles second it would be
a great help):

$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 category name
   // echo "This is category b" . $temp ."/b, and it's titles are as
following:br"; //display it
  //  echo "this is title a href='update.php?passed=". $r["id"]
."'b" . $r["title"] . "/b/abr";
  }

  if ($temp != $r["catagory"]) // because it's sorted by category, this
method will work!
echo "This is category b" . $temp. "/b, and it's titles are as
following:br"; //display it
  // update last category name

  $temp = $r["catagory"];
 // echo "This is category b" . $temp. "/b, and it's titles are as
following:br";
  echo "this is title a href='update.php?passed=". $r["id"] ."'b" .
$r["title"] . "/b/abr";

}



""elias"" [EMAIL PROTECTED] wrote in message
9a246s$mcv$[EMAIL PROTECTED]">news:9a246s$mcv$[EMAIL PROTECTED]...
 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
titley
titlez

 that what you said, right?
 okay, try 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["category"]; // get category name
 echo "This is category $temp, and it's titles are as following:br";
//
 display it
   }

   if ($temp != $r["category"]) // because it's sorted by category, this
 method will work!
 echo "This is category $temp, and it's titles are as following:br";
//
 display it
   // update last category name
   $temp = $r["category"];
   echo "this is title " . $r["title"] . "br";

 }
 **
 -
 ""Mark Bayfield"" [EMAIL PROTECTED] wrote in message
 9a1u3q$k81$[EMAIL PROTECTED]">news:9a1u3q$k81$[EMAIL PROTECTED]...
  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 the wrong way, if
you
  can see whats wrong with my code plase help, or point me in some
 direction),
 
   $query = mysql_query("SELECT DISTINCT catagory from article order by
  catagory");
   $query2 = mysql_query ("SELECT * from article ORDER BY catagory");
 
   for ($index = 0; $index  mysql_num_rows($query); $index++) {
$Catagory = mysql_fetch_row ($query) or die (mysql_error());
$name1 =  mysql_fetch_row ($query2) or die (mysql_error());
$x = $name1;
$result1 = array_unique($Catagory);
$result = array_merge($Catagory, $name1);
 
 print ("$result1[0]BR");
 for ($x=0; $x == $result1[0]; $x++) {
 print ("nbsp;nbsp;nbsp;nbsp;a
  href='update.php?passed=$name1[0]'$name1[2]/abr\n");
 }
   }
 
  I am trying everything to get it do just print the following:
 
  Catagory
  title1
  title2
  Catagory1
  title3
  title4
 
  Please help me out
 
  thanks
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]
 



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




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 category name
echo "font face=verdana size=1b" . $temp ."/b/fontbr";
//display it
}

   if( $temp != $r["catagory"]) // because it's sorted by category, this
method will work!
 // echo "This is category2 b" . $temp. "/b, and it's titles are as
following:br"; //display it
  // update last category name

 if ($temp = $r["catagory"])
  echo "font face=verdana size=1b" . $temp . "/b/fontbr";
  echo "nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;a href='update.php?passed=".
$r["id"] ."'font face=verdana size=1b" . $r["title"] .
"/b/font/abr";

}

""Mark Bayfield"" [EMAIL PROTECTED] wrote in message
9a3d8o$e2l$[EMAIL PROTECTED]">news:9a3d8o$e2l$[EMAIL PROTECTED]...
 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 off. I have modified the code as such (if
 you can help so that the catagory is first and the titles second it would
be
 a great help):

 $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 category name
// echo "This is category b" . $temp ."/b, and it's titles are as
 following:br"; //display it
   //  echo "this is title a href='update.php?passed=". $r["id"]
 ."'b" . $r["title"] . "/b/abr";
   }

   if ($temp != $r["catagory"]) // because it's sorted by category, this
 method will work!
 echo "This is category b" . $temp. "/b, and it's titles are as
 following:br"; //display it
   // update last category name

   $temp = $r["catagory"];
  // echo "This is category b" . $temp. "/b, and it's titles are as
 following:br";
   echo "this is title a href='update.php?passed=". $r["id"] ."'b"
.
 $r["title"] . "/b/abr";

 }



 ""elias"" [EMAIL PROTECTED] wrote in message
 9a246s$mcv$[EMAIL PROTECTED]">news:9a246s$mcv$[EMAIL PROTECTED]...
  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
 titley
 titlez
 
  that what you said, right?
  okay, try 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["category"]; // get category name
  echo "This is category $temp, and it's titles are as
following:br";
 //
  display it
}
 
if ($temp != $r["category"]) // because it's sorted by category, this
  method will work!
  echo "This is category $temp, and it's titles are as
following:br";
 //
  display it
// update last category name
$temp = $r["category"];
echo "this is title " . $r["title"] . "br";
 
  }
  **
  -
  ""Mark Bayfield"" [EMAIL PROTECTED] wrote in message
  9a1u3q$k81$[EMAIL PROTECTED]">news:9a1u3q$k81$[EMAIL PROTECTED]...
   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 the wrong way, if
 you
   can see whats wrong with my code plase help, or point me in some
  direction),
  
$query = mysql_query("SELECT DISTINCT catagory from article order by
   catagory");
$query2 = mysql_query ("SELECT * from article ORDER BY catagory");
  
for ($index = 0; $index  mysql_num_rows($query); $index++) {
 $Catagory = mysql_fetch_row ($query) or die (mysql_error());
 $name1 =  mysql_fetch_row ($query2) or die (mysql_error());
 $x = $name1;
 $result1 = array_unique($Catagory);
 $result = array_merge($Catagory, $name1);
  
  print ("$result1[0]BR");
  for ($x=0; $x == $result1[0]; $x++) {
  print ("nbsp;nbsp;nbsp;nbsp;a
   href='update.php?passed=$name1[0]'$name1[2]/abr\n");
  }
}
  
   I am trying everything to get it do just print the following:
  
   Catagory
   title1
   title2
   Catagory1
   title3
   title4
  
   Please help me out
  
   thanks
  
  
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
   

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){
 //first time category
 $current_category = $r['category'];
 printf("b%s/bbr\n",$current_category);
 }
 //Now just print the title in this row
 printf("$indent_stri%s/ibr\n",$r['title']);
}

basil

At 11:58 AM 3/31/2001 +1000, Mark Bayfield wrote:
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 off. I have modified the code as such (if
you can help so that the catagory is first and the titles second it would be
a great help):

$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 category name
// echo "This is category b" . $temp ."/b, and it's titles are as
following:br"; //display it
   //  echo "this is title a href='update.php?passed=". $r["id"]
."'b" . $r["title"] . "/b/abr";
   }

   if ($temp != $r["catagory"]) // because it's sorted by category, this
method will work!
 echo "This is category b" . $temp. "/b, and it's titles are as
following:br"; //display it
   // update last category name

   $temp = $r["catagory"];
  // echo "This is category b" . $temp. "/b, and it's titles are as
following:br";
   echo "this is title a href='update.php?passed=". $r["id"] ."'b" .
$r["title"] . "/b/abr";

}



""elias"" [EMAIL PROTECTED] wrote in message
9a246s$mcv$[EMAIL PROTECTED]">news:9a246s$mcv$[EMAIL PROTECTED]...
  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
 titley
 titlez
 
  that what you said, right?
  okay, try 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["category"]; // get category name
  echo "This is category $temp, and it's titles are as following:br";
//
  display it
}
 
if ($temp != $r["category"]) // because it's sorted by category, this
  method will work!
  echo "This is category $temp, and it's titles are as following:br";
//
  display it
// update last category name
$temp = $r["category"];
echo "this is title " . $r["title"] . "br";
 
  }
  **
  -
  ""Mark Bayfield"" [EMAIL PROTECTED] wrote in message
  9a1u3q$k81$[EMAIL PROTECTED]">news:9a1u3q$k81$[EMAIL PROTECTED]...
   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 the wrong way, if
you
   can see whats wrong with my code plase help, or point me in some
  direction),
  
$query = mysql_query("SELECT DISTINCT catagory from article order by
   catagory");
$query2 = mysql_query ("SELECT * from article ORDER BY catagory");
  
for ($index = 0; $index  mysql_num_rows($query); $index++) {
 $Catagory = mysql_fetch_row ($query) or die (mysql_error());
 $name1 =  mysql_fetch_row ($query2) or die (mysql_error());
 $x = $name1;
 $result1 = array_unique($Catagory);
 $result = array_merge($Catagory, $name1);
  
  print ("$result1[0]BR");
  for ($x=0; $x == $result1[0]; $x++) {
  print ("nbsp;nbsp;nbsp;nbsp;a
   href='update.php?passed=$name1[0]'$name1[2]/abr\n");
  }
}
  
   I am trying everything to get it do just print the following:
  
   Catagory
   title1
   title2
   Catagory1
   title3
   title4
  
   Please help me out
  
   thanks
  
  
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
   To contact the list administrators, e-mail: [EMAIL PROTECTED]
  
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]
 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: 

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 = mysql_query($qry);
 $current_category = "";
 while ($r = mysql_fetch_array($result)){
  if ($r['category']  $current_category){
  //first time category
  $current_category = $r['category'];
  printf("b%s/bbr\n",$current_category);
  }
  //Now just print the title in this row
  printf("$indent_stri%s/ibr\n",$r['title']);
 }

 basil

 At 11:58 AM 3/31/2001 +1000, Mark Bayfield wrote:
 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 off. I have modified the code as such
(if
 you can help so that the catagory is first and the titles second it would
be
 a great help):
 
 $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 category name
 // echo "This is category b" . $temp ."/b, and it's titles are as
 following:br"; //display it
//  echo "this is title a href='update.php?passed=". $r["id"]
 ."'b" . $r["title"] . "/b/abr";
}
 
if ($temp != $r["catagory"]) // because it's sorted by category, this
 method will work!
  echo "This is category b" . $temp. "/b, and it's titles are as
 following:br"; //display it
// update last category name
 
$temp = $r["catagory"];
   // echo "This is category b" . $temp. "/b, and it's titles are as
 following:br";
echo "this is title a href='update.php?passed=". $r["id"]
."'b" .
 $r["title"] . "/b/abr";
 
 }
 
 
 
 ""elias"" [EMAIL PROTECTED] wrote in message
 9a246s$mcv$[EMAIL PROTECTED]">news:9a246s$mcv$[EMAIL PROTECTED]...
   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
  titley
  titlez
  
   that what you said, right?
   okay, try 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["category"]; // get category name
   echo "This is category $temp, and it's titles are as
following:br";
 //
   display it
 }
  
 if ($temp != $r["category"]) // because it's sorted by category,
this
   method will work!
   echo "This is category $temp, and it's titles are as
following:br";
 //
   display it
 // update last category name
 $temp = $r["category"];
 echo "this is title " . $r["title"] . "br";
  
   }
   **
   -
   ""Mark Bayfield"" [EMAIL PROTECTED] wrote in message
   9a1u3q$k81$[EMAIL PROTECTED]">news:9a1u3q$k81$[EMAIL PROTECTED]...
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 the wrong way,
if
 you
can see whats wrong with my code plase help, or point me in some
   direction),
   
 $query = mysql_query("SELECT DISTINCT catagory from article order
by
catagory");
 $query2 = mysql_query ("SELECT * from article ORDER BY catagory");
   
 for ($index = 0; $index  mysql_num_rows($query); $index++) {
  $Catagory = mysql_fetch_row ($query) or die (mysql_error());
  $name1 =  mysql_fetch_row ($query2) or die (mysql_error());
  $x = $name1;
  $result1 = array_unique($Catagory);
  $result = array_merge($Catagory, $name1);
   
   print ("$result1[0]BR");
   for ($x=0; $x == $result1[0]; $x++) {
   print ("nbsp;nbsp;nbsp;nbsp;a
href='update.php?passed=$name1[0]'$name1[2]/abr\n");
   }
 }
   
I am trying everything to get it do just print the following:
   
Catagory
title1
title2
Catagory1
title3
title4
   
Please help me out
   
thanks
   
   
   
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail:
[EMAIL PROTECTED]