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
https://forums.phpfreaks.com/topic/246954-echoing-the-value-of-mysql-field-data/
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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.