Hopefully I can explain this well enough, but I run a movie/DVD review website and after a couple hundred DVD reviews, I've run across a slight problem. In MySQL, I have a entry within my dvdreviews DB with a column called "edition". Well, what my problem is I don't know how to handle the coding side on my dvd review page if that entry is blank.<br /><br />Right now I have:<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><?php<br /><br />$titleinfo2 = @mysql_query("SELECT title, year, edition FROM dvd_reviews WHERE id='$id'");<br />if (!$titleinfo2) {<br />Â Â exit('<p>Error retrieving information from database.<br />'.<br />Â Â Â Â Â Â 'Error: ' . mysql_error() . '</p>');<br />}<br /><br />while ($info2 = mysql_fetch_array($titleinfo2)) {<br />Â Â Â Â $title = $info2['title'];<br />Â Â Â Â $year = $info2['year'];<br />Â Â Â Â $edition = $info2['edition'];<br />Â Â Â Â echo "$title ($year) - $edition";<br />}<br />?><!--c2--></div><!--ec2--><br /><br />If $edition is empty, how do I handle that dash?<br /><br />Also, I have a DVD reviews archive page where I have the same kind of issue:<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->$titlelist = @mysql_query("SELECT name, dvd_reviews.id, year, rating_overall, title, list_title, edition FROM critic, dvd_reviews WHERE criticid=critic.id ORDER BY list_title ASC");<br /><br />while ($listing = mysql_fetch_array($titlelist)) {<br />Â Â Â Â $id = $listing['id'];<br />Â Â Â Â $title = $listing['title'];<br />Â Â Â Â $edition = $listing['edition'];<br />Â Â Â Â $year = $listing['year'];<br />Â Â Â Â $name = $listing['name'];<br />Â Â Â Â $rating = $listing['rating_overall'];<br /><br />Â Â Â Â echo"<br />Â Â Â Â <TR><br />Â Â Â Â Â Â <TD CLASS='rindex-year'>$year</TD><br />Â Â Â Â Â Â <TD CLASS='rindex-link'><a href=http://www.totalchoicehosting.com/forums/lofiversion/index.php/'reviews/DVD/read.php?id=$id'><b>$title</b></a> ($edition)</TD><br />Â Â Â Â Â Â <TD CLASS='rindex-critic'>$name</TD><br />Â Â Â Â Â Â <TD CLASS='rindex-rating'><img src=http://www.totalchoicehosting.com/forums/lofiversion/index.php/'images/star_ratings/$rating.gif' HEIGHT='25' ALT='$rating'></TD><br />Â Â Â Â </TR>";<br />}<!--c2--></div><!--ec2--><br /><br />Here, the edition is in parenthesis and I obviously don't want it to look like: Movie Title (), <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/tongue.gif" style="vertical-align:middle" emoid="" border="0" alt="tongue.gif" /><br /><br />Any help in this would be appreciated.<br /><br />Thanks <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid="" border="0" alt="smile.gif" /><!--content-->
Hi, MovieMan.<br /><br />For the first example, there are a couple of ways to do it:<br /><br />echo "$title ($year)" . ($edition)?"<b> - $edition</b>":"";<br />or<br />$display_edition = ($edition)?"<b> - $edition</b>":"";<br />echo "$title($year)$display_edition";<br /><br />The second method probably involves less code for your second example:<br /><br />$display_edition = ($edition)?"<b> ($edition)</b>":"";<br />echo"<br />. . .<br /><TD CLASS='rindex-link'><a href=http://www.totalchoicehosting.com/forums/lofiversion/index.php/'reviews/DVD/read.php?id=$id'><b>$title</b></a>$display_edition</TD><br />. . .";<br /><br />Hope that helps. If I've misunderstood the question, just keep asking.<br /><br />Edit:<br />I just realized that I pasted your BBCode tags into mt answer and they got seen as BOLD tags for this post. Sorry. I'll bet you get the point, though.<!--content-->
Thanks for your help Jim.<br /><br />This one worked for my review page:<br /><br />$display_edition = ($edition)?" - $edition":"";<br />echo "$title($year)$display_edition";<br /><br /><br />But when I tried the other for my review index page, all the editions were absent. Not sure why because that's the same code as the other code that worked. I also tried it with the dash instead of parantheses, but same result.<!--content-->
Nevermind, I made a dumb mistake <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/tongue.gif" style="vertical-align:middle" emoid="" border="0" alt="tongue.gif" /> Everything works now.<br /><br />Thanks again for your help Jim <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid="" border="0" alt="smile.gif" /><!--content-->
Don't you hate when that happens?<br />I'm glad it worked out for you.<!--content-->
Hi, MovieMan.<br /><br />For the first example, there are a couple of ways to do it:<br /><br />echo "$title ($year)" . ($edition)?"<b> - $edition</b>":"";<br />or<br />$display_edition = ($edition)?"<b> - $edition</b>":"";<br />echo "$title($year)$display_edition";<br /><br />The second method probably involves less code for your second example:<br /><br />$display_edition = ($edition)?"<b> ($edition)</b>":"";<br />echo"<br />. . .<br /><TD CLASS='rindex-link'><a href=http://www.totalchoicehosting.com/forums/lofiversion/index.php/'reviews/DVD/read.php?id=$id'><b>$title</b></a>$display_edition</TD><br />. . .";<br /><br />Hope that helps. If I've misunderstood the question, just keep asking.<br /><br />Edit:<br />I just realized that I pasted your BBCode tags into mt answer and they got seen as BOLD tags for this post. Sorry. I'll bet you get the point, though.<!--content-->
Thanks for your help Jim.<br /><br />This one worked for my review page:<br /><br />$display_edition = ($edition)?" - $edition":"";<br />echo "$title($year)$display_edition";<br /><br /><br />But when I tried the other for my review index page, all the editions were absent. Not sure why because that's the same code as the other code that worked. I also tried it with the dash instead of parantheses, but same result.<!--content-->
Nevermind, I made a dumb mistake <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/tongue.gif" style="vertical-align:middle" emoid="" border="0" alt="tongue.gif" /> Everything works now.<br /><br />Thanks again for your help Jim <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid="" border="0" alt="smile.gif" /><!--content-->
Don't you hate when that happens?<br />I'm glad it worked out for you.<!--content-->