Re: Unable to send variables to MySQL table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Stewart Priest wrote:
<snip>
What is the structure of that table?
</snip>

+---------------+--------------+------+-----+---------+-------+
| Field         | Type         | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+-------+
| invoice_no    | int(10)      | YES  |     | NULL    |       |
| item1_desc    | varchar(255) | YES  |     | NULL    |       |
| item1_cost    | float        | YES  |     | NULL    |       |
| item2_desc    | varchar(255) | YES  |     | NULL    |       |
| item2_cost    | float        | YES  |     | NULL    |       |
| item3_desc    | varchar(255) | YES  |     | NULL    |       |
| item3_cost    | float        | YES  |     | NULL    |       |
| item4_desc    | varchar(255) | YES  |     | NULL    |       |
| item4_cost    | float        | YES  |     | NULL    |       |
| delivery_cost | float        | YES  |     | NULL    |       |
| customer_id   | int(10)      | YES  |     | NULL    |       |
| comments      | varchar(255) | YES  |     | NULL    |       |
+---------------+--------------+------+-----+---------+-------+


This is not a good structure. Have you thought about taking item* columns to a separate table?

Table invoices:
+---------------+--------------+------+-----+---------+-------+
| Field         | Type         | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+-------+
| invoice_no    | int(10)      | YES  |     | NULL    |       |
| delivery_cost | float        | YES  |     | NULL    |       |
| customer_id   | int(10)      | YES  |     | NULL    |       |
| comments      | varchar(255) | YES  |     | NULL    |       |
+---------------+--------------+------+-----+---------+-------+

Table invoices_items:
+---------------+--------------+------+-----+---------+-------+
| Field         | Type         | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+-------+
| item_no       | int(10)      | YES  |     | NULL    |       |
| invoice_no    | int(10)      | YES  |     | NULL    |       |
| item_desc     | varchar(255) | YES  |     | NULL    |       |
| item_cost     | float        | YES  |     | NULL    |       |
+---------------+--------------+------+-----+---------+-------+

And columns should be able to hold NULL values only if they can be empty. I'm sure you don't want invoice_no to be NULL ;)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux