darkenroyce Posted April 15, 2008 Share Posted April 15, 2008 Hi Guys I'm running a update query which is supposed to enter some data for me via a drop dialogue box from a web page with a form. The code is as follows: $sql="SELECT id FROM squad ORDER BY id DESC LIMIT 1"; $f=mysql_query($sql, $con) or die(mysql_error()); $a = mysql_fetch_assoc($f); $row = $a++; $sql_s="UPDATE squad SET play = '$_POST[sub]' WHERE us='$id' AND id='$row'"; mysql_query($sql_s, $con) or die(mysql_error()); The code for the drop down dialogue box is as follows: <select name="sub"> <?php $con = mysql_connect("localhost", "root") or die(mysql_error()); mysql_select_db("dbase", $con) or die(mysql_error()); $s = "SELECT id, name, value, position FROM players WHERE position='Q'"; $q = mysql_query($s, $con); while($queryCol= mysql_fetch_array($q)){ echo '<option value="' . $queryCol ['id'] . '">' . $queryCol ['id'] . ' ' . $queryCol ['name'] . ' - ' . $queryCol ['player'] .'</option>'; } ?></select> The drop dialogue box passes option value id to the update query which needs to populate where us=$id (the row's id & primary key) and to the next blank row after the previous row has been filled in the table hence $a++. It does not since MySQL table displays 0 when the id should be there. Is it because the fetch is incorrect? It is a two part registration system that requires the user id to ensure that the new user can register their details and then they choose players from the drop down box to place in the squad they intend to submit. Please advise. If this is unclear, I can provide you with my msn address via a private message. Cheers, Darkenroyce Link to comment https://forums.phpfreaks.com/topic/101241-query-was-emptywhy/ Share on other sites More sharing options...
ohdang888 Posted April 15, 2008 Share Posted April 15, 2008 don't use array's in your query.... $sub = $_POST; Link to comment https://forums.phpfreaks.com/topic/101241-query-was-emptywhy/#findComment-517934 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.