Jump to content

[SOLVED] So confused... Query Problems..


monkeytooth

Recommended Posts

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

$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.

 

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.