hey guys,
I need help.
I have a select box which is filled dynamically with all my tables.
so if I select a table it shows the content below.
I also have a function which draws an insert form and one which should submit the entry(the latter doesn't work).
I can't manage to pass the column drawed. It doesn't even pass the $table name in the function...I'm so confused.
all I need is be able to insert the row and show the table. So have the main page which has an include file.
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'>";
$counter = 0;
while ($row = mysql_fetch_array($result,MYSQL_NUM)) {
$counter++;
print "\t<tr>\n";
print "<td><b>$row[0]</b></td>";
if ($counter == 1 || $counter ==2) {
print "<td>auto</td>";
} else {
print "<td><INPUT TYPE='text' NAME='data' VALUE='' SIZE=13 style=\"border-style:
solid\"></td>";
}
print "\t</tr>\n";
}
print "</table>\n";
print "<br>";
print "<INPUT TYPE='submit' name='submit2' value='Insert a new Row' style=\"border-style:
solid\">";
print "</FORM>";
print "</DIV>";
}
function insertNew_row($table,$data){
if($submit2){
$query = "INSERT INTO $table('$row[0]') VALUES('".$POST['data']."')";
$result=_mysql_que($query);
print "record added";
#echo $sql; // to show what sent
}
}
?>