Forum Moderators: coopster
$query = ("SELECT * FROM sitemap") or die("something messed up");
$result = mysql_query($query);
while ($cat_row = mysql_fetch_row($result)){
print("<option value=\"" . $cat_row[1] . "\">" . $cat_row[1]);
$query = ("SELECT * FROM sitemap") or die("something messed up");
$result = mysql_query($query);
$result2 = mysql_fetch_array($result);
while ($cat_row = mysql_fetch_array($result)){
print("<option value=\"" . $cat_row[1] . "\">" . $cat_row[1]);
} EDIT:
ok scratch that. It didnt work when I added another input with the same category. 2 worked 3 of the same doesn't.
Again.....help.
just tried it but cant seem to get it working:
$query = ("SELECT DISTINCT category FROM sitemap") or die("something messed up");
$result = mysql_query($query);
while ($cat_row = mysql_fetch_row($result)){
print("<option value=\"" . $cat_row[1] . "\">" . $cat_row[1]);
SELECT DISTINCT (category) FROM....
added
To use array_unique try the following:
$query = ("SELECT category FROM sitemap") or die("something messed up");
$result = mysql_query($query);while ($row = mysql_fetch_array($result))
{$categories[] = $row['category'];
}
$newData = array_unique($categories);
foreach ($newData as $dropDown)
{
echo "<option>" . $dropDown . "</option>\n";
}
Think that should work.
[edited by: dreamcatcher at 4:43 pm (utc) on Aug. 4, 2004]
Ahh well thanks for your efforts. Let me know if you think of anything else.
Im doing this on my own computer where I have MYSQL and PHP and APACHE so Im assuming it is something to do with my setup.