insert data
| From: | massimo | Date: | Sun, 06 Apr 2003 18:13:42 +0000 |
| Subject: | insert data | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-26869@lists.php.net to get a copy of this message | ||
hey this is my function which should create an insert form in relation to the table I choose. I don't have the insert button working yet.
all i need is first of all keep the first 2 $id and $created of each table without text field(because they're auto).
then I need to make able to enter the data in the form and submit...a new record should appear in the table below.
http://www.qaip.com/~sub/week6_a.php
as soon as you load the page it won't work but if you choose the table it will.
thanks, sub
function insert_row($table,$data){
$query = "DESCRIBE $table";
$result = mysql_query($query);
print "<DIV ALIGN=\"CENTER\">";
print "<table border=1>\n";
print "<FORM METHOD='POST' ACTION='$PHP_SELF'>";
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
print "\t<tr>\n";
print "<td><b>$row[0]</b></td>";
print "<td><INPUT TYPE='text' NAME='data' VALUE='$data' SIZE=13 style=\"border-style:solid\"></td>";
print "\t</tr>\n";}
print "<INPUT TYPE='submit' name='submit2' value='Insert a new Row' style=\"border-style: solid\">";
print "</FORM>";
print "</table>\n";
print "</DIV>";
#if($submit2){
#print "$data";
#}
}
?>