How to create a table in PHP with MySQL?

Let’s learn how to create a table in PHP with MySQL. The most accurate or helpful solution is served by Stack Overflow.

There are ten answers to this question.

Best solution

create a table with php and mysql using SHOW CREATE TABLE

I'm trying to create an exact duplicate of another table via php by using SHOW CREATE TABLE. I only want to change the table name, but I haven't figured out how to do that yet. If the old table's name is table_1, I want the new one to be table_2. This didn't work. Didn't really expect it to, but that's how far I got: $t = $DB->fetch("SHOW CREATE TABLE table_1"); $t[0] = "table_2"; $DB->query($t[1]);

Answer:

The following query will create new table, column attributes and indexes will also be copied. CREATE...

Read more

domino at Stack Overflow Mark as irrelevant Undo

Other solutions

Answer:

Execute a SELECT INTO statement on the mysql database: INSERT INTO destination_table (id, first_name...

Read more

community wiki at wiki.answers.com Mark as irrelevant Undo

Where do I put down the codes that create a talbe in mysql using php?

Do I create a new php file and name it with anything I want, then input the codes (below) "in" the php file? A table should be created in mysql after I save this php file? <?php // Make a MySQL Connection mysql_connect("localhost"...

Answer:

yeah, you should create a file with a php extension and just paste this code there. I have made some...

Read more

Mohammed at Yahoo! Answers Mark as irrelevant Undo

Create downloadable iCal files in PHP/MySQL/Bootstrap?

I have a PHP webpage that lists events happening at a conference by reading from a MySQL database. Is there an easy way to have PHP create downloadable iCal files so people can download individual events to their iphones/Androids etc., without my having...

Answer:

The quick and dirty way is to probably tack whatever variable you need onto the end of the link e.g...

Read more

dnash at Ask.Metafilter.Com Mark as irrelevant Undo

How can I get the remainder from two values from MySQL in PHP?

Hi, I'm new to php and MySQL. I'm trying to create a chart which displays numerical data from MySQL. I could draw a chart with pChart, but I couldn't get the remainder of two values. Well, this is MySQL data table (first row and second row) --------...

Answer:

You want to use modular arithmetic, which, in MySQL, is the '%' operator.  So, for example: mysql&#...

Read more

Joe Emison at Quora Mark as irrelevant Undo

What method is best to use country table in mysql, php? JSON, xml or mysql table?

i am using country table in mysql using php? which is the best method ?   xml or JSON or mysql table JSON: eg json.php $country = array('1'=>'india','2'=>'us'); xml:       <xml>         <countries>               <country id...

Answer:

I would use a cached xml file, but that is strictly a matter of my own personal preference. All are...

Read more

Jim Barrett at Quora Mark as irrelevant Undo

Php creating a table in mysql using a variable as table name.?

Hi, Im trying to create a table in mysql using variable $signupemail as table name. Here is my code mysql_select_db("profiles",$connect); mysql_query("CREATE TABLE ".$signupemail." (FirstName VARCHAR(30), LastName VARCHAR(30...

Answer:

its been a while since i worked with php, but it looks good to me. try setting the query as a variable...

Read more

Yang at Yahoo! Answers Mark as irrelevant Undo

HOw do I get PHP/MySQL output in a table to be numbered?

have a MySQL DB that has a DB w/ one table, that having two rows. I use this PHP to retrieve it and put it into a table (It's for hi-scores): $fetch = mysql_query("SELECT * FROM scores ORDER BY score DESC LIMIT 10"); while($row = mysql_fetch...

Answer:

First thing, it's not a good idea to do SELECT *, just select the fields that you want, even if * is...

Read more

m3thus3l... at Yahoo! Answers Mark as irrelevant Undo

How to import mysql data from one host(Godady) to another host ? i am trying to import this but every time it gives an error like -- Table structure for table accessaccess -- CREATE TABLE IF NOT EXISTS  accessaccess (   aidaid INT( 11 ) NOT NULL AUTO_INCREME

-- Table structure for table accessaccess -- CREATE TABLE IF NOT EXISTS accessaccess ( aidaidINT( 11 ) NOT NULL AUTO_INCREMENT , maskmaskVARCHAR( 255 ) NOT NULL DEFAULT '', typetypeVARCHAR( 255 ) NOT NULL DEFAULT '', statusstatusTINYINT( 4 ) NOT NULL...

Answer:

this isn't an error message, it is the mysqldump output for the CREATE TABLE statement.

Read more

Stewart Smith at Quora Mark as irrelevant Undo

How to insert data into a mysql table from an array using php?

am new to php and need help regarding array insertion into mysql table i have an array when i add and item to the shopping cart $_session['cart_array'] = array("item_id" => $pid, "quantity"=>1) now if i have one item in cart...

Answer:

if it were me, I would loop through the array and build the query, then execute it once. Like this ...

Read more

Ahmad at Yahoo! Answers Mark as irrelevant Undo

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.