Jump to content

*RESOLVED* Why doesnt this script update database?


JJohnsenDK

Recommended Posts

I have this script where i want the text in the dropdown menu to be update to my database when pressed submit. The script works fine if i do a input type="text". But when i use the dropdown the text doesnt update, why?

[code]
<?php
include('mysql_connect.php');
$hent = "SELECT * FROM wof_pl";
$bestgk = mysql_query($hent) or die(mysql_error());
?>
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post" >
<br />
<select name="d1">
<?php
$hent = "SELECT * FROM wof_pl";
$bestgk = mysql_query($hent) or die(mysql_error());

while ($vis = mysql_fetch_array($bestgk)){
$df = $vis['wof_pl_pos'];

if ($df == "Forsvar"){
?>
<option value="<?php $df = $vis['wof_pl_name']; ?>"><?php $df = $vis['wof_pl_name']; echo $df; ?></option>

<?php
}
}
?>
</select>

<br /><br />
<input type="submit" value="send" name="submit" />
</form>

<?php
if(isset($_POST['submit'])){
$hent = mysql_query("INSERT INTO wof_best SET wof_best_d1 = '".$_POST['d1']."'");
}
?>
[/code]
Well there isnt a error really because the script inserts a blank field into the database, as if there isnt any text in the drop down menu. My quess is how do i update the database with the text or option i select in the dropdown menu?

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.