I am trying to build a simple admin tool that will allow the user to add data to several tables. Basically, it is for a real estate database and I want them to be able to select an Id and change the featured_listing field to yes or no.
I have to form that I want to use below...I am just not sure how to take the data from the form and have it add the data to the database table.
I have the form going to a script called featured_script.php but I dont know how to get the varables from the form into the right tables.
Can anyone offer suggestions on what I should do? This script is going to be used to either add new data....or edit data already there.
I have the following form:
<?
$username="xxx";
$password="xxx";
$database="xxx";
mysql_pconnect('xxx',$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
// Below will display listings for specific ID///
mysql_query("CREATE TEMPORARY TABLE temp_featured select Id from residential where lister_office_name='Town'");
mysql_query("INSERT INTO temp_featured select Id from multi where lister_office_name='Town'");
mysql_query("INSERT INTO temp_featured select Id from mobile where lister_office_name=''Town");
mysql_query("INSERT INTO temp_featured select Id from land where lister_office_name='Town");
mysql_query("INSERT INTO temp_featured select Id from condo where lister_office_name='Town");
mysql_query("INSERT INTO temp_featured select Id from commercial where lister_office_name='Town");
$query="SELECT * FROM temp_featured";
$result=mysql_query($query) or die (mysql_error());
$num=mysql_numrows($result);
?>
<form method="POST" action="featured_script.php">
<table width="100%">
<tr>
<td width="22%">Select MLS to edit</td>
<td width="1%"> </td>
<td width="77%"><select size="1" name="featuredid">
<?
while ($row = mysql_fetch_array($result)) // this will grab the results from query
{
?>
<option value="<? echo $row[Id]; ?>"><? echo $row[Id] ;?></option>
<?
}
?>
</select></td>
</tr>
<tr>
<td width="22%">Is this a featured listing?</td>
<td width="1%"> </td>
<td width="77%">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50%"><input type="radio" value="yes" checked name="featured_yn">Yes</td>
<td width="50%"><input type="radio" name="featured_yn" value="no">no</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="22%"> </td>
<td width="1%"> </td>
<td width="77%"> </td>
</tr>
<tr>
<td width="22%">Agents Comments:</td>
<td width="1%"> </td>
<td width="77%"><textarea rows="5" name="agent_comment" cols="39"></textarea></td>
</tr>
</table>
<p><input type="submit" value="Submit" name="B1"></p>
</form>