Freedom-n-Democrazy Posted September 12, 2011 Share Posted September 12, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/246954-echoing-the-value-of-mysql-field-data/ Share on other sites More sharing options...
Freedom-n-Democrazy Posted September 12, 2011 Author Share Posted September 12, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/246954-echoing-the-value-of-mysql-field-data/#findComment-1268290 Share on other sites More sharing options...
Freedom-n-Democrazy Posted September 12, 2011 Author Share Posted September 12, 2011 ... or to even simplify what I am trying to do: $sizeM = (table(products)id1.sizem); if ($SizeM == "0") {echo "";} else {echo "Size M: $sizeM";} Quote Link to comment https://forums.phpfreaks.com/topic/246954-echoing-the-value-of-mysql-field-data/#findComment-1268293 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.