RE: [PHP] Dynamic menu
| From: | César Aracena | Date: | Sat, 20 Jul 2002 23:12:45 +0000 |
| Subject: | RE: [PHP] Dynamic menu | ||
| References: | 1 | Groups: | php.db php.general |
| Request: | Send a blank email to php-db+get-20674@lists.php.net to get a copy of this message | ||
Thanks Mark and John.
>From the MySQL manual:
"The options [for the SELECT statement] DISTINCT, DISTINCTROW and ALL
specify whether duplicate rows should be returned. The default is (ALL),
all matching rows are returned. DISTINCT and DISTINCTROW are synonyms
and specify that duplicate rows in the result set should be removed."
$query = "SELECT DISTINCT * FROM tbl_name";
I hope this helps!
-Mark
> Use GROUP_BY in your query on the some_else column
>
> SELECT * FROM table GROUP BY some_else
>
> ---John Holmes...
> > -----Original Message-----
> > From: César Aracena [mailto:icaam@icaam.com.ar]
> > Sent: Saturday, July 20, 2002 3:13 PM
> > To: PHP General List; PHP DB List
> > Subject: [PHP] Dynamic menu
> >
> > Hi all. Im making a few dynamic menus that grab information from a
> > MySQL DB. What I dont know is how to print only one line of each. I
> > dont want a Drop Down List displaying 4 times the same line if the
> > information is repeated in 4 rows in the same table. What Im using
is
> > something like:
> >
> > $query = SELECT * FROM tbl_name;
> > $result = mysql_quiery($query) or die(mysql_error());
> > $num_rows = mysql_num_rows($result);
> >
> >
> > <select name="select_name">
> > <option SELECTED>Select Something</option>
> >
> > for ($i=0; $i<$num_rows: $i++)
> > {
> > $row = mysql_fetch_array($result);
> > print ("<option
>
> value=\"".$row[some]."\">".$row[some_else]."</option>");
> > }
> >
> > </select>
> >
> > This works just fine now that I dont have 2 or more rows with the
> > some_else repeated. Is there a WHERE or something like that which
I
> > can use for this?
> >
> > Thanks in advancem
> >
> > <mailto:webmaster@icaam.com.ar> Cesar Aracena
> > CE / MCSE+I
> > Neuquen, Argentina
> > +54.299.6356688
> > +54.299.4466621
> >