Jump to content

if else statement...I think?


NoDoze

Recommended Posts

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

<?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!

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>
";
}
?>

}

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.