
01-23-04, 09:14 AM
|
 |
Community VIP
|
|
Join Date: Oct 2003
Location: Chicago, IL
Posts: 2,171
Thanks: 3
Thanked 9 Times in 9 Posts
|
|
Here is an example:
PHP Code:
<?php $location = "localhost"; $username = "username"; $password = "password"; $database = "database"; $conn = mysql_connect("$location","$username","$password"); if (!$conn) die ("Could not connect MySQL"); mysql_select_db($database,$conn) or die ("Could not open database"); mysql_query("CREATE TABLE tablename ( column1 VARCHAR(20), column2 VARCHAR(20), column3 VARCHAR(20), column4 VARCHAR(20))"); Repeat this set of code 3 times to insert 3 rows: $insert = "INSERT INTO users (column1,column2,column3, column4) VALUES ('Value1','Value2','Value3','Value4')"; mysql_query($insert) or die ("Could not add data to the table"); ?>
Let me know if you have any other questions.
Quote:
|
Originally Posted by MikeNL
Hi,
Does anyone know how to create HTML tables (3 rows, 4 colums) from a MySQL query in PHP?
I have a script that works, but the first row only has 3 colums, all the other rows have 4.
THX!!!!!
|
|