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 '';
}

Link to comment
Share on other sites

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  :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.