Passing variables from a Function into a DB
Posted: Wed Jun 01, 2005 8:07 pm
Hi All,
The following code populates a Dropdown menu from the DB and now I wish to post these setting into another table. I'm guessing I need to somehow transform the Select statement into an input statement with a name. But i'm unsure on how to do this. Does anyone have any pointers?
TAI, Will.
The following code populates a Dropdown menu from the DB and now I wish to post these setting into another table. I'm guessing I need to somehow transform the Select statement into an input statement with a name. But i'm unsure on how to do this. Does anyone have any pointers?
TAI, Will.
Code: Select all
<?
include "../includes/functions.inc";
include "../includes/common_db.inc";
$link_id = db_connect($db_materials);
if(isset($_GET['commented']))
{
echo('Your comment has been posted.');
$link_id = db_connect($db_materials);
$category = $_GET['category'];
$colloPaperName = $_GET['colloPaperName'];
$sql_add = "INSERT INTO summary values('','$category','$paperName')";
mysql_query($sql_add) or die(mysql_error());
}
else {
?>
<form method='get' action='<? echo $_SERVER['PHP_SELF']; ?>'>
<input type='hidden' name='commented' value='set'>
<?
echo "<table class=\"materials\"><tr>";
$addSummary=array('Category','Paper Name');
$sumTitles = array(listCat1(),'paperName');
for($x = 0; $x<count($addSummary); $x++) {
echo "<tr><td width=\"200px\" colspan=\"2\" valign=\"top\">".$addSummary[$x]."</td>\n";
echo "<td width=\"200px\" colspan=\"2\">$sumTitles[$x]</td></tr>\n";
}
?>
<tr><td width=\"200px\" colspan=\"2\" valign=\"top\"><input type='reset' class='btn' value='Reset'></td>
<td width=\"200px\" colspan=\"2\"><input type='submit' class='btn' value='Add'></td></tr>
</form></table>
<?
}
?>