Hello,
I am trying to build a program that will allow users to submit there website to my directory. I have all of the code done. But the last part of the program will not insert the information into the database.
I have created an admin section so I can choose which one's I want to go into the database and which one's I don't want and be able to delete.
I've tried this two differnet ways. The first way is I added the INSERT INTO ... into the value tag of select form element. That did not work. Then I tried an If statement with if ($value = 1) ($value2 = INSERT INTO....) then I had another if statement that said if ($value = 2) ($value2 = DELETE Where...) (this is not exact code) None of the above work. So i have the code down here for webadmin.php and add_resource.php. If any one could help me find away with an select tag in the form to insert or delete it would be a big help.
<?
$fred = 0;
/ declare some relevant variables /
$DBhost = "";
$DBuser = "";
$DBpass = "";
$DBName = "";
$table = "web_submit";
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable toconnect to database");
@mysql_select_db("$DBName") or die("Unable to select database $DBName");
$sqlquery = "SELECT * FROM $table LIMIT 10";
$result = mysql_query($sqlquery);
$number = mysql_numrows($result);
$i = 0;
if ($number < 1) {
print "<CENTER><P>There Were No Results for Your Search</CENTER>";
}
else {
while ($number > $i) {
$id = mysql_result($result,$i,"id");
$url = mysql_result($result,$i,"url");
$description = mysql_result($result,$i,"description");
print "<form method='post' action='add_resource.php'>";
print "<table width='100%'>";
print "<tr>
<td width='25%'><center><input type='hippen' name='id' value='$id'></center></td>
<td width='25%'><center><input type='text' name='url' value='$url'></center></td>
<td width='25%'><input type='text' name='description' value='$description'></td>
<td width='25%'><select name='value'><option value='INSERT INTO webmaster VALUES ('$id','$url','$description')'>INSERT</option><option value='2'>Delete</option></select></td>
</tr>";
print "</table>";
print "<center><input type='submit' name='submit' Value='Add'></center>";
print "</form>";
$i++;
}
}
?>
add_resource.php
<?
/ declare some relevant variables /
$DBhost = "";
$DBuser = "";
$DBpass = "";
$DBName = "";
$table = "webmaster";
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable toconnect to database");
@mysql_select_db("$DBName") or die("Unable to select database $DBName");
$sqlquery = "$value";
$results = mysql_query($sqlquery);
mysql_close();
print "<HTML><TITLE> PHP and MySQL </TITLE><BODY
BGCOLOR=\"#FFFFFF\"><center><table border=\"0\"
width=\"500\"><tr><td>";
print "<p><font face=\"verdana\" size=\"+0\"> <center>You
Just Entered This Information Into the
Database<p><blockquote>";
print "ID : $id<P> URL : $url<P> Description : $description </blockquote></td></tr></table>
</center></BODY></HTML>";
?>
Thanks,