NoDoze Posted March 11, 2009 Share Posted March 11, 2009 Right now I have this: <?php $result = mysql_query("SELECT * FROM projects WHERE cata='restoration' ORDER BY RAND()"); while($row = mysql_fetch_array($result)) { echo " <tr> <td class='sub-table-images'> <a href=".$row['cutsheet'] . "><img src=".$row['thumb'] . " width='180' height='115' border='0' /></a> </td> <td class='sub-table'><div class='sub-table-im-header'> ".$row['title'] ." </div> <div class='sub-table-im-txt'> ".$row['disc'] ." </div> <div class='sub-table-im-loc'> ".$row['county'] . " " . $row['state'] ." </div> <div class='sub-table-im-txt'> (<a href=".$row['cutsheet'] . ">pdf</a>) </div> </td> </tr> "; } ?> ...my question is...for example this... (<a href=".$row['cutsheet'] . ">pdf</a>) If there is no value in the msql db I want the line above to not appear. Example: <html> <body> <?php $d=date("D"); if ($d=="Fri") echo "Have a nice weekend!"; else echo "Have a nice day!"; ?> </body> </html> I've used something like this before, but how would I implement it if there is no value, 'else' do this...? I hope the question makes sense... Thanks for any input! Link to comment https://forums.phpfreaks.com/topic/149022-if-else-statementi-think/ Share on other sites More sharing options...
lonewolf217 Posted March 11, 2009 Share Posted March 11, 2009 try reading this over http://www.phpfreaks.com/forums/index.php/topic,242568.0.html Link to comment https://forums.phpfreaks.com/topic/149022-if-else-statementi-think/#findComment-782520 Share on other sites More sharing options...
NoDoze Posted March 11, 2009 Author Share Posted March 11, 2009 Oh wow! Didn't know u could do that! I'll give it a try. Thanks! ...couldn't find anything about it here or via google.... Link to comment https://forums.phpfreaks.com/topic/149022-if-else-statementi-think/#findComment-782534 Share on other sites More sharing options...
NoDoze Posted March 11, 2009 Author Share Posted March 11, 2009 <?php $result = mysql_query("SELECT * FROM projects WHERE cata='restoration' ORDER BY RAND()"); while($row = mysql_fetch_array($result)) { echo " <tr> <td class='sub-table-images'> <a href=".$row['cutsheet'] . "><img src=".$row['thumb'] . " width='180' height='115' border='0' /></a> </td> <td class='sub-table'><div class='sub-table-im-header'> ".$row['title'] ." </div> <div class='sub-table-im-txt'> ".$row['disc'] ." </div> <div class='sub-table-im-loc'> ".$row['county'] . " " . $row['state'] ." </div> <div class='sub-table-im-txt'> (<a href="if (!empty($row['cutsheet'])) { .stripslashes($row['cutsheet']). }">pdf</a>) </div> </td> </tr> "; } ?> What am I doing wrong here? I get a blank page... ..the elevator isn't reaching the top floor right now for me... Thanks! Link to comment https://forums.phpfreaks.com/topic/149022-if-else-statementi-think/#findComment-782542 Share on other sites More sharing options...
lonewolf217 Posted March 11, 2009 Share Posted March 11, 2009 I think this will work, just be careful of where your echo starts and ends <?php $result = mysql_query("SELECT * FROM projects WHERE cata='restoration' ORDER BY RAND()"); while($row = mysql_fetch_array($result)) { echo " <tr> <td class='sub-table-images'> <a href=".$row['cutsheet'] . "><img src=".$row['thumb'] . " width='180' height='115' border='0' /></a> </td> <td class='sub-table'><div class='sub-table-im-header'> ".$row['title'] ." </div> <div class='sub-table-im-txt'> ".$row['disc'] ." </div> <div class='sub-table-im-loc'> ".$row['county'] . " " . $row['state'] ." </div> "; if (!empty($row['cutsheet'])) { echo "<div class='sub-table-im-txt'> <a href=" . $row['cutsheet'] . ">pdf</a> </div>"; } echo "</td> </tr> "; } ?> } Link to comment https://forums.phpfreaks.com/topic/149022-if-else-statementi-think/#findComment-782544 Share on other sites More sharing options...
NoDoze Posted March 11, 2009 Author Share Posted March 11, 2009 LOL...I was *slightly* off Sweet thanks! Link to comment https://forums.phpfreaks.com/topic/149022-if-else-statementi-think/#findComment-782552 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.