how to check whether all columns in an array have null value

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
harikamat
Forum Newbie
Posts: 1
Joined: Wed Jul 29, 2009 3:25 am

how to check whether all columns in an array have null value

Post by harikamat »

Hi,

I have to create a table to store product details. But the structure is inconsistent. For eg:- some product requires only six columns, some 7 columns, etc. and the column names would also be different as given below:

CODE - CARTRIDGE MODEL NO. - PRINTER DESCRIPTION - COLOR - TYPE
CODE - CARTRIDGE MODEL NO. - PRINTER DESCRIPTION - PRODUCT

From the above you can figure out that the product properties are inconsistent. In such a scenario how should i design a database table, and how should i display the product details on php page.

Can anyone help

regards,

harish
Last edited by onion2k on Wed Jul 29, 2009 4:12 am, edited 1 time in total.
Reason: Moved to the Databases forum.
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: how to check whether all columns in an array have null value

Post by papa »

Allow null values in those columns that doesn't require a value.

When displaying the content you can for example use if(!empty($db_value) echo $value
or however you would like to display the data.

Play around a little bit and show us what you come up with.
Post Reply