Jump to content

Drop Down Boxes selecting selected option


iceblox

Recommended Posts

Hi Guys how would i make a PHP Query select the one that has been selected in a drop down box?

 

This is query i tried which didnt work

 

 

Can anyone please tell me what is wrong with it?

 

 

$query = "SELECT * FROM deals WHERE FreeGift <> 'Offer.FreeGift' AND FreeGift <> ' 'GROUP BY FreeGift ASC";

$result = mysql_query($query);

if (mysql_num_rows($result) > 
                            0)
{

while($row = mysql_fetch_row($result))     

if($row[4] == '$FreeGift') {
                $auto = '<option value="' . $row[4] . '">' . $row[4] . '</option>';
                }
                else {
                $auto = '<option value="' . $row[4] . '">' . $row[4] . '</option>';
	}

echo '' . $auto . '';

}
else
{
echo '';
}

It just returns a reference to one row. Using array you have access to all the rows returned by the sql statement.

 

Also it is better practice to refer to the variable by name and not by array number....ie $row[4] should be something like $row["freegift"] if your field name was called freegift of course in the table  :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.