cs1h Posted September 19, 2008 Share Posted September 19, 2008 Hi, I have a script that searches a database and returns all the relevant results into a table, this works fine but one section of the script is designed to so that it only shows a line of HTML if their is a result in a certain column. The script is, <?php $art = $_GET['id']; mysql_connect("localhost","xxx","poppop"); mysql_select_db("xxxs") or die("Unable to select database"); $sql = "SELECT * FROM fsss WHERE forumid ='$art' ORDER BY lastpost DESC"; $result = mysql_query($sql); $num_rows = mysql_num_rows($result); if($num_rows == 0) { echo ""; } else { while($row = mysql_fetch_array($result)) { $title = $row['name']; $date = $row['started']; $started_date = date_create ($date); $started_year = date_format ($started_date, 'dS F Y'); $started_hour = date_format ($started_date, 'G:ia'); $last_post_date = $row['lastpost']; $last_date = date_create ($last_post_date); $last_year = date_format ($last_date, 'dS F Y'); $last_hour = date_format ($last_date, 'G:ia'); $views = $row['views']; $replies = $row['replies']; $author = $row['author']; $last_author = $row['last_author']; $threadid = $row['threadid']; // this next line is the problem if ($last_author == ""){ echo ("");} else { $laster = "<span class=\"grey_small\">posted $last_year at $last_hour by</span> <span class=\"blue_small\">$last_author</span>";} echo "<div> <div id=\"topic_box\"> <div class=\"topic_left\"><span class=\"blue_large\"><a href=ssss.php?ed=$threadid&id=$art>$title<a/></span></div> <div class=\"topic_right\"><span class=\"grey_small\">$replies reply, $views views</span></div> <div class=\"topic_info\"><span class=\"grey_small\">posted $started_year at $started_hour by</span> <span class=\"blue_small\">$author</span></div> <div class=\"topic_info\">$laster</div> </div></div>"; } } ?> I have highlighted the problem line in the script. The issue is that I just want the line of html to show up if the data is in the same row as the other data. But at the moment the HTML is showing up if there is data in that column on any of the rows. I hope this makes sense. I presume it will involve arrays but I don't know how to do this. Can anyone help? Thanks, Colin Link to comment https://forums.phpfreaks.com/topic/124977-help-with-search-results/ Share on other sites More sharing options...
cs1h Posted September 19, 2008 Author Share Posted September 19, 2008 Sorry for marking it as solved, I thought it was but it's not. Can anyone help? Thanks, Colin Link to comment https://forums.phpfreaks.com/topic/124977-help-with-search-results/#findComment-645802 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.