Reputation: 53
I have a script that creates a SQL table for me as below
if ($con = mysql_connect($host, $username, $password)) {
if (mysql_select_db($db_name)) {
$sql = "CREATE TABLE ".$ac_system."_credits (id INT NOT NULL
AUTO_INCREMENT , PRIMARY KEY (id) , account_nr CHAR(10) , credits CHAR(10))";
if (mysql_query($sql, $con)) {
$insertSuccessful = true;
} else {
echo $sql;
print_r($_POST);
echo "\n" . mysql_error($con);
echo "mysql err no : " . mysql_errno($con);
}
I would like to add another line/s to populate the above table with fixed information
ID - 1 Credits - 10 ACCOUNT_NR - 1
The above data is constant and doesn't need to be changed once the table is created I am not sure how to populate it in conjunction with the creation of the table. I can populate it from a seperate PHP script but need all to be done on one page
Upvotes: 1
Views: 51
Reputation: 558
Maybe you should execute another one query just after successful table creation:
//some php code here
$insertSuccessful = true;
mysql_query( "INSERT INTO $ac_system ( account_nr, credits ) VALUES ( '1', '10' )", $sql );
// and here
Upvotes: 1