Jump to content

Echoing the value of MySQL field data


Freedom-n-Democrazy

Recommended Posts

I have a MySQL table called "products":

+------+-------+-------+-------+

| id  | sizes | sizem | sizel |

+------+-------+-------+-------+

| 1    | 2    | 0    | 1    |

| 2    | 3    | 1    | 0    |

+------+-------+-------+-------+

 

What I am wanting to know is if I can make PHP print a value from it, but only if it is not a zero.. something like:

 

$sizeL = (table(products)id1.sizel);

if (table(products)id1.sizel == "0") {echo "";} else {echo "$sizeL";}

 

Yeah I know the above code is far from beeing valid, but is the best I could come up with. heh :)

Link to comment
Share on other sites

Oh God, I have totally botched this post!

I will start over.

 

 

I have a MySQL table called "products":

+------+-------+-------+-------+

| id  | sizes | sizem | sizel |

+------+-------+-------+-------+

| 1    | 3    | 2    | 2    |

+------+-------+-------+-------+

 

What I want to do is produce the following on a webpage:

 

Size S: 3

Size M: 2

Size L: 2

 

Using Size M for an example, to achieve this, I am thinking of code that would go along the lines of something like this:

$sizeM = (table(products)id1.sizem);

if (table(products)id1.sizem == "0") {echo "";} else {echo "Size M: $sizeM";}

 

Just for example that Size M (sizem) in my MySQL database equaled 0, then the webpage would render like this:

 

Size S: 3

Size L: 2

 

How would I write that in PHP?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.