monkeytooth Posted May 12, 2008 Share Posted May 12, 2008 Well I asked this a few hours ago, but I think I might have been asking the wrong thing. $dbconn = mysql_connect($sq_hst, $sq_unme, $sq_pzwrd) or die("Error: " . mysql_error()); mysql_select_db($database) or die("Could not select database"); $query="SELECT * FROM tolland_news"; $result1=mysql_query($query) or die ("Error in query: $query. " . mysql_error()); $result1a = mysql_fetch_array( $result1 ); $resulta = mysql_num_rows($result1); $tblclrz = ""; //echo $resulta; if ($resulta == "0") { echo "Currently there is no news to display"; } else { while ($row = mysql_fetch_array($result1)) { if ($row['news_status'] == "c22") { if ($tblclrz == "") { $tblclrz = "#EBEBEB"; } elseif ($tblclrz == "#EBEBEB") { $tblclrz = "#C0C0C0"; } elseif ($tblclrz == "#C0C0C0") { $tblclrz = "#EBEBEB"; } else { $tblclrz = "#FF0000"; } $newz_body = substr($row['news_body'], 0, 150) . "<font color=\"#FF9900\">...</font>"; echo "<table border=\"0\" width=\"610\" cellspacing=\"0\" cellpadding=\"0\" style=\"font-family: Verdana; font-size: 8pt\">"; echo "<tr>"; echo "<td style=\"font-family: Verdana; font-size: 8pt\" bgcolor=\"" . $tblclrz . "\"><u>"; echo "<b>Posted: </b>" . $row['news_time'] . " / " . $row['news_date'] . "</u></td>"; echo "</tr>"; echo "<tr>"; echo "<td style=\"font-family: Verdana; font-size: 8pt\" bgcolor=\"" . $tblclrz . "\">$newz_body</td>"; echo "</tr>"; echo "<tr>"; echo "<td style=\"font-family: Verdana; font-size: 8pt\" bgcolor=\"" . $tblclrz . "\" align=\"right\" valign=\"top\">"; echo "<a href=\"" . $row['ID'] . "\">Read more..</a></td>"; echo "</tr>"; echo "</table>"; //echo $tblclrz; } } } mysql_close(); Above the code I am using.. The issue is I cant get the first entry in the database to display. No matter what I change add remove move around in the script. I have everything stored in a mysql database. And I have usually had no problems with what I am attempting to do now in the past. So I am extremely stumped. Is there anyone out there thats able to point out what I am doing wrong, or whats wrong.. Link to comment https://forums.phpfreaks.com/topic/105349-solved-so-confused-query-problems/ Share on other sites More sharing options...
Barand Posted May 12, 2008 Share Posted May 12, 2008 $query="SELECT * FROM tolland_news"; $result1=mysql_query($query) or die ("Error in query: $query. " . mysql_error()); $result1a = mysql_fetch_array( $result1 ); // REMOVE $resulta = mysql_num_rows($result1); Remove the line indicated. It reads the first row but you do nothing with it, effectively throwing it away. Link to comment https://forums.phpfreaks.com/topic/105349-solved-so-confused-query-problems/#findComment-539557 Share on other sites More sharing options...
monkeytooth Posted May 13, 2008 Author Share Posted May 13, 2008 ahh.. can't belive i over looked that.. thank you now it works like intended Link to comment https://forums.phpfreaks.com/topic/105349-solved-so-confused-query-problems/#findComment-539564 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.