I got this in index.php:
<form action="add.php"method="POST">
<select name="qtable">
<?php
$dbname = 'ii';
if (!mysql_connect('localhost', 'root', NULL)) {
print 'Could not connect to mysql';
exit;
}
$result = mysql_list_tables($dbname);
if (!$result) {
print "DB Error, could not list tables\n";
print 'MySQL Error: ' . mysql_error();
exit;
}
while ($row = mysql_fetch_row($result)) {
print "<option value=\"".$row[0]."\">".$row[0]."</option>\n";
}
mysql_free_result($result);
?>
</select>
<input type="submit" name="selectDB" value="Select">
and I got this in add.php:
<form action="add.php" method="POST">
<input type="text" name="part" size="20">
<input type="text" name="name" size="20">
<input type="submit" name="submit" value="ÇÖÇÝå">
</form>
<?php
print $qtable;
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['name'])){
$dbConnection = mysql_connect('localhost', 'root', NULL);
mysql_select_db('ii', $dbConnection);
mysql_query("INSERT INTO ".$qtable."(part, name) VALUES (".$_POST['part'].", '".$_POST['name']."')", $dbConnection);
header('Location: show.php');
print mysql_error();
exit;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['qtable'])){
$qtable = $_POST['qtable'];
}
?>
<form action="show.php" method="POST">
<input type="submit" name="showButton" value="äãÇíÔ">
</form>
Now my problem is... it doesn't get the variable qtable which is the SQL table from the dropdown box in index.php. How do I fix this?