PDA

View Full Version : Problem With Table


antubob
05-06-2006, 12:34 PM
im using php(4.x) and mysql
i want to keep record for item that every customer have by from my shop. and it will display details of item such as quantity,color and type.

im planning to create individual table for each customer and userid will be use for naming the new table.

i create coding as below to retrieve data from table 123:
where's 123 is the table name and same as userid
<?php
$id = "123";
$result = mysql_query("SELECT * FROM $id") or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
echo $row['type'];
}?>

but when i upload and run it.. i display an error

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '123' at line 1

guelphdad
05-06-2006, 03:09 PM
First of all your design is very poor. Don't create a new table for each customer. create a table holding information on your customers and identify them by a customerid.

You should read a tutorial about database normalization.

There is a good one located here (http://dev.mysql.com/tech-resources/articles/intro-to-normalization.html).

You are getting an error message because you can't name a table that starts with a digit.

antubob
05-07-2006, 01:50 PM
thank and it work perfectly.. how to change fonts in php?

guelphdad
05-07-2006, 03:51 PM
I think you would need to clarify that question, exactly what you mean, but post it in the php forum since it has nothing to do with mysql which is what this forum is for.