Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Sure, you can execute a command like:</p> <pre><code>CREATE TABLE IF NOT EXISTS `test1` ( ... ); </code></pre> <p>To get your table creation query, issue this command after you've already created it in SQL:</p> <pre><code>SHOW CREATE TABLE `test1`; </code></pre> <p><strong>Edit:</strong></p> <p>Note that you don't have to create the table in SQL directly, but since you already have, issuing the above command will give you exactly what you need to include in PHP to have it create the table on a future installation should the table not exist.</p> <p>Note also that as @Jeremy suggests, you don't have to "roll your own" code to import a data file to a table. Once you've created the table, you can use <code>LOAD DATA INFILE...</code> to populate the table.</p> <p><strong>Edit 2:</strong></p> <p>Here is an example based on your comment:</p> <pre><code>&lt;?php // Connect to the database server $connection = mysql_connect('localhost', 'root', 'bonzo123'); if (!$connection) die('Could not connect: ' . mysql_error()); // Create database gameDB if (mysql_query('create database gameDB', $connection)) { echo "Database gameDB created successfully.\n"; } else { echo 'Error creating database: ' . mysql_error() . "\n:"; } // select which database to use mysql_select_db('gameDB', $connection); // create table test1 if it doesn't already exist mysql_query('CREATE TABLE IF NOT EXISTS test1 ( v1 varchar(100), v2 varchar(100), v3 varchar(100), v4 varchar(100), v5 varchar(100), v6 varchar(100), v7 varchar(100), v8 varchar(100), v9 varchar(100), v10 varchar(100)', $connection); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload