You are here: Re: [PHP] Unable to send variables to MySQL table « PHP « IT news, forums, messages
Re: [PHP] Unable to send variables to MySQL table

Posted by M on 10/21/20 11:31

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 ;)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация