lost with a form

Hi,

I’ve been messing with php a bit and got lost.
the code creates a form with a dropbox that gets populated from the db, this far it works fine.
but the drop_id should be posted to addfood.php but like this it does not post at all.
i have no idea anymore how to correct my problem.

[code]<?php
// get info from DB
$query=“SELECT * FROM food”;
$result = mysql_query ($query);

// start form
echo “”;
echo “<select name=save_id=’’>”;

//fetching & messing with array
while($nt=mysql_fetch_array($result)){
$drop_id = $nt[ID];
$drop_food = $nt[Food];

echo “$drop_food”;
}
echo “”;
echo “”;
echo “”;
?>
[/code]

I’m a noob @ php so the fix is pobably verry simple i just don’t see it.
any help is greatly apreciated.

Hi, I’ve been messing for this for hours and hours…

so by now i dont realy know anymore what i’ve changed…
1 thing i did change last was:

echo "<select name=save_id=''></option>";

because the post was messed up with %3 blabla… wich was the "’’> signs.
all in all it had more then 1 problem :wink:

this is the working script, in case people have problems in the future.

[code]<?php
// get info from DB
$query=“SELECT * FROM food”;
$result = mysql_query ($query);

echo “”;
echo “”;

//fetching & messing with array
while($nt=mysql_fetch_array($result)){
$drop_id = $nt[ID];
$drop_food = $nt[Food];
echo “$drop_food”;
}
echo “”;
echo “”;
echo “”;
?>[/code]

Why are you closing a non existent option?
[php]

<?php // get info from DB $query=mysql_query("SELECT * FROM food"); echo ""; echo ""; //fetching & messing with array while($nt=mysql_fetch_array($query)) { echo "$nt[Food]"; } echo ""; echo ""; echo ""; ?>

[/php]
fixed and cleaned up.

Thanx, i checked out the changes you made to it ;).

hte variables in the array are not needed i agree, i just thougth this would make easyer for me… but in fact its just more typing work :wink:

i’m now also clear on using the " ’ your fix shows it nicely… alot of snippets you find around the net are not perfect at all… i see something different every time.

big thanks mate, i’ve learned alot from this.

I just added the ’ ’ in there to keep it xhtml compliant. You can use like quotes inside each other, the second one just has to be escaped, but for me, its just easier to not do it, to much extra typing :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service