Forum Moderators: coopster

Message Too Old, No Replies

Hiding Text when MySQL has no data value

hiding text on a website if there is no data value adjacent to it

         

stuckinbed

9:04 pm on Mar 27, 2005 (gmt 0)

10+ Year Member



hey everybody! i am stumped

When a user signs into my website, he/she sees the following hypothetical personalized information:

Name: sample user
Birthdate: 01/01/2005
Favorite color: brown
Favorite TV show: Desperate Housewives

Say my user did NOT specify his/her favorite color in the MySQLdatabase. It would look like this:

Name: sample user
Birthdate: 01/01/2005
Favorite color:
Favorite TV show: Desperate Housewives

Why should the text "favorite color" still be there? It is not necessary. I want it to look like this:

Name: sample user
Birthdate: 01/01/2004
Favorite TV show: Desperate Housewives

sorry if i'm an idiot, but i can't figure this out! also, just to let you know, i'm using dreamweaver.

thanks a lot for any help :-)

HughMungus

9:07 pm on Mar 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How about making the display of the information conditional?

if ($row[favoritecolor]<>"") echo 'Favorite Color: '.$row[favoritecolor].'':

wrightee

11:43 pm on Mar 27, 2005 (gmt 0)

10+ Year Member



... or you could conditionally make it 'not specified' either in the PHP or make the db do the legwork:

select *,if(fave_colour!='',fave_colour,'Not specified') as fave_colour from your_table where blah blah blah

stuckinbed

7:26 am on Mar 28, 2005 (gmt 0)

10+ Year Member



thanks a lot! it worked perfectly :-) i chose to use the php conditional method