What code would I use to display text in the database, yet have it show default text if nothing is added to the database? Basically if a user signs up at my site and adds their code number for a CJ banner, then it shows their CJ banner on the posts they start on my blog. If they do not add a CJ number, then it shows my number, the default number. I have the program where the information is added to the database fine, and also it pulls added ID's fine, but if someone doesn't add an ID it really messes my banners up because there is no ID added to the banner code at all, so I would like it to add my number until they can add their own CJ number. I can program what I need, if someone can guide me to a tutorial or lesson that explains the coding concept. I just don't know where to begin.
Where ever you use the code number to display a banner, do something like this. if( isset($codeNumber) { echo "Display normally"; } else { echo "Display default"; } Code (markup):
Doesn't a if() clause suffices? <? if(empty($cj_number)) { $cj_number = "Default Number Here"; } ?> PHP:
If you're using MySql, you can enter a default value on the database field in the table structure - there's no need to code anything.
Thanks everyone!!!! I got it working, now I can dance a jig WOOOHOOOO I've been working on this for 10 hours straight and I was about to go ga ga. Thanks tons!!! It's working wonderfully for me now!!!!