...

View Full Version : sorting by drop down...



xflip
03-24-2004, 04:24 AM
can anyone please teach me how to do this kind of thing?

http://squareinsider.com/news/archive.php


As you can see, theres a dropdown... and when you choose one in the drop down, it shows the articles that matches the category...

Im trying to do the same but with not news articles but fanarts...

I only have this so far..
(this is fanart.php)

$sql = mysql_query('SELECT DISTINCT artist FROM site_fanartsindex');


for ($x = 0; $x < mysql_num_rows($sql); $ex++)
{
$row3 = mysql_fetch_array($sql);
$artist = $row['artist'];
$showartist .= "<option value=fanartartist.php?artist={$artist}>$artist</option>";



echo "
<select class="form" onchange="window.open(this.options[this.selectedIndex].value,'_self')" size="1" name="page">
<option value="#">ARTIST</option>
<option value="#">-----------------------------</option>
$showartist
</select>




then in fanartist.php



$sql = mysql_query("SELECT * FROM site_fanartsindex WHERE artist=$artist");

ECHO "STUFF HERE, got this part done, this is the easy one ^^ "






basically, can anyone provide more "lectures", fixes and stuff. I have never tested the code and I DOUBT it will work.


thanks!

Az`
03-24-2004, 06:00 PM
IF you don't have globals on, you'll need to put $_POST['artist'].

But, actually it looks like you've named the jumpmenu 'page' - Therefore you'd have to use:


$page = $_POST['page'];

$sql = mysql_query("SELECT * FROM site_fanartsindex WHERE artist = 'page'");



Remember the option value is whatever you're assigning to the 'name' variable.
Remember that:

<option value="#">ARTIST</option>

There, as far as values are concerned, ARTIST is merely output to the browser, it's the 'value="#"' bit that counts.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum