Page is a not externally linkable
magneto - 7:47 am on Dec 3, 2010 (gmt 0)
Here's a basic rundown of my code:
<form action="http://www.test.com/insert-data.php" method="post">
<table>
<tr>
<td><div align="left">Items</div></td>
<td><div align="left">
<select onchange="house(form)" name="houses">
<option selected="selected" value="100000" >House 1</option>
<option value = "80000" >House 2</option>
<option value= "300000" ">House 3</option>
</select>
</div></td>
</tr>
</table>
<input name="cost" type="text" class="textbox"/>
<input name="submit" type="submit" value="Submit" /></form>
In essence, what this code does is it creates a table with a dropdown menu of 3 houses, each one with a different value.
Now i am using this php code to store the values in a mysql database.
<?php
mysql_connect("localhost", "user", "pass") or die(mysql_error());
mysql_select_db("data1") or die(mysql_error());
$houses = $_POST["houses"];
mysql_query("INSERT INTO test(houses) values('$houses') ")
or die(mysql_error());
;?>
Thanks for your helpNow what i would like to do is to store both the value and the name of the selection made by the user. For example, if the user selects the first option, the data stored in the database is only 100000. How can i modify my php or the html code from the form to be able to insert the 100000 and also House 1 into the database. I need both values to be passed on to my database.