Jump to content

Recommended Posts

<?php
$sql = "SELECT * FROM $table ORDER BY id DESC LIMIT 25";
$result = mysql_query($sql) or die("Error ". mysql_error(). " with query ". $sql);
if(mysql_num_rows($result) >= 1)
{ 
echo '<div id="front_page_post_container">';
while($row = mysql_fetch_array($result))
{
	echo '<div id="hover_div">';
	echo '<div id="title_container">';
	echo '<h2>';
	echo '<a href="post.php?id='.$row['id'].'">'.stripslashes($row['title']).'</a>';
	echo '</h2>';
	echo '</div>';
	echo '<div id="post_container">';
	echo stripslashes(nl2br(substr($row['post'],0,450)));
	echo ' <a href="post.php?id='.$row['id'].'">Read on...</a>';
	echo '</div>';

have a counter variable initiated before your while loop and set it to zero.

inside the loop check this variable. if it is zero, highlight the current item however you want, then increment the counter.  then as it goes through the loop no other entry will be highlighted

Not sure how to right that. Can you point me in the right direction?

 

 

<?php
$sql = "SELECT * FROM $table ORDER BY id DESC LIMIT 25";
$result = mysql_query($sql) or die("Error ". mysql_error(). " with query ". $sql);
if(mysql_num_rows($result) >= 1)
{ 

$count = mysql_num_rows($result);
   
if  {
   $class = '0';
   }else{
   $class = '';
   }

    
echo '<div id="front_page_post_container">';
while($row = mysql_fetch_array($result))
{
	echo '<div id="hover_div" class="{$class}">';
	echo '<div id="title_container">';
	echo '<h2>';
	echo '<a href="post.php?id='.$row['id'].'">'.stripslashes($row['title']).'</a>';
	echo '</h2>';
	echo '</div>';
	echo '<div id="post_container">';
	echo stripslashes(nl2br(substr($row['post'],0,450)));
	echo ' <a href="post.php?id='.$row['id'].'">Read on...</a>';
	echo '</div>';

 

 

 

Ok i see what you mean, but I tried the following and it has no effect.

 

<?php
$sql = "SELECT * FROM $table ORDER BY id DESC LIMIT 25"; 
$result = mysql_query($sql) or die("Error ". mysql_error(). " with query ". $sql); 
if(mysql_num_rows($result) >= 1) 
{  
    echo '<div id="front_page_post_container">'; 
    $RsCounter = 0;
    while($row = mysql_fetch_array($result)) 
    { 
        $RsCounter++;
        if($RsCounter == 0){
             echo '<div id="hover_div" style="font-size: 15px; font-weight: bold;">'; 
        } else {
             echo '<div id="hover_div">'; 
        }
        echo '<div id="title_container">'; 
	echo '<h2>';
	echo '<a href="post.php?id='.$row['id'].'">'.stripslashes($row['title']).'</a>';
	echo '</h2>';
	echo '</div>';
	echo '<div id="post_container">';
	echo stripslashes(nl2br(substr($row['post'],0,450)));
	echo ' <a href="post.php?id='.$row['id'].'">Read on...</a>';
	echo '</div>';
	echo '</div>';
}
echo '</div>';
}
else
{
echo "That record does not exist!";
}
?>

 

 

<?php
    $RsCounter = 0;
    while($row = mysql_fetch_array($result)) 
    { 
        $RsCounter++;
        if($RsCounter == 0){
             echo '<div id="hover_div" style="font-size: 15px; font-weight: bold;">'; 
        } else {
             echo '<div id="hover_div">'; 
        }

 

you are incrementing the counter before you ever check it.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.