Jump to content

[SOLVED] Problem with displaying newest material


timmah1

Recommended Posts

I'm trying to pull the newest items from the database, but I only want to pull the 2 newest items.

 

The problem is, it's doubling the people. It is listing the same thing twice, so I have 4.

 

Here is what I'm doing

$query = "SELECT * FROM users WHERE date_registered < '$today' LIMIT 2";

 

Here is the whole code

<?
$today = date("Y-m-d");
include "DB_config.php";
echo "<table width=\"100%\" cellpadding=\"10\" border=\"0\" class=\"fieldset\">";

//set 3 to 6 of you want 4 columns. Set it to 5 if you want 5, etc
$numcols = 2; // how many columns to display
$numcolsprinted = 0; // no of columns so far

// get the results to be displayed
$query = "SELECT * FROM users WHERE date_registered < '$today' LIMIT 2";
//$queryall2 = $query2.$sorted2.$querylimit2;
$queryall = $query.$sorted.$querylimit;
$mysql_result = mysql_query($queryall);

// get each row
while($myrow = mysql_fetch_assoc($mysql_result))
{

//get data - eg, 
$first = $myrow['first'];
$last = $myrow['last'];
$photo = $myrow['photo'];
$city = $myrow['city'];
$state = $myrow['state'];
$Username = $myrow['Username'];

if ($numcolsprinted == $numcols) {
print "</tr>\n<tr>\n";
$numcolsprinted = 0;
}

$photos23 = "SELECT * FROM photos WHERE main = '1' LIMIT 2";
$result23 = mysql_query($photos23);
while($row23 = mysql_fetch_array( $result23 )){

// output row from database
echo "<td width=\"74%\"><table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"5\">
        <tr valign=\"top\">
          <td width=\"13%\">";
	  if($row23[user]==$myrow[username]){
	  echo "<img src=\"users/$row23[photo]\" width=\"75\" border=\"1\"> ";
	  }
	  else {
	  echo "<img src=\"no_photo.jpg\">";
	  }
	  echo" </td>
          <td width=\"87%\">
	  <table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
            <tr>
              <td>$myrow[first] $myrow[last]<br>$myrow[username]</td>
            </tr>
            <tr>
              <td>$myrow[city] $myrow[state]</td>
            </tr>
          </table>
	  <br>
          <a href=\"?cid=profile&id=$myrow[username]\">View Profile</a></td>
        </tr>
      </table></td>\n";;

// bump up row counter
$numcolsprinted++;


}// end while loop

$colstobalance = $numcols - $numcolsprinted;
for ($i=1; $i<=$colstobalance; $i++) {

}
}

print "</table>\n";

?>

 

Can anybody help me out?

 

Thanks in advance

Ok, let's scratch the time thing

 

if I just want to display the last two people that signed by based on the id (highest number being the newest), it still does the same thing.

 

It works fine on another page

 

You can look here

 

http://www.cheezyfries.net/god

 

The top right corner is the same script, just altered a little, but the one below it is what's giving me the problems

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.