Jump to content

[SOLVED] Simple script not diplaying a list


DeathStar

Recommended Posts

Hi there i have a script that i recently changed(style) and now it just wont dislpay more than one entry.

The script is supposed to list users in the database but it is only displaying 1.

There is more than 1 entry in the database though..

 

here is my script:

<?php
session_start();

require "spamhead.php";

if (!$_GET['user'])
{
$by    = "sid";
$ord   = ($_GET['ord']);
$cnt   = mysql_query("SELECT sid FROM spammers");
$membs = mysql_num_rows($cnt);
$pages = (int)($membs / 100) + 1;

if ($membs % 100 == 0)
{
  $pages--;
}

print "

<style type='text/css'>

.style5 {color: #000000; font-weight: bold; font-family: Arial; }
body {
background-color: #000000;
background-image: url();
}

mystl { 
color: #333333; 
}


tr.off {
background: #CCCCCC;
}

tr.on {
background: #FF0000;
}

</style>";
$userid = $_SESSION['uid'];

print "<center>Pages:</font> ";

for ($i = 1; $i <= $pages; $i++)
{
  $stl = ($i - 1) * 100;
  print "<a href='index.php?st=$stl&by=$by&ord=$ord'>$i</a> ><br>";
}

print "
<center><font color=white><h4><a href='insertspam.php'>Add Spammer</a><br><br />Order By: <a href='index.php?by=username&ord=$ord'>Username</a><br>
<a href='index.php?ord=asc'>Ascending</a>|<a href='index.php?ord=desc'>Descending</a><br /><br />";
$sm  = mysql_query("SELECT * FROM spammers ORDER BY $by $ord LIMIT 100");
$s   = mysql_fetch_array($sm);
$no1 = $st + 1;
$no2 = $st + 100;
print "<font color=white>Showing $no1 to $no2 by order of $by $ord.
<style type='text/css'>
<!--
.style3 {color: #FFFFFF; font-weight: bold; }
body {
background-color: #000000;
background-image: url();
}

.style11 {font-family: Arial; font-size: small; font-weight: bold; color: #000000; }
tr.off {
background: #F2F2F2;
}

tr.on {
background: #FD0000;
}
-->
</style>
<div align='center'>
  <table width='676' height='62' border='0' bordercolor='#CCCCCC' cellpadding='0' cellspacing='2' bgcolor='#FFFFFF'>
    <tr>
      <td width='90' bgcolor='#FD0000'><div align='center' class='style11'><div align='center'>Name</div></div></td>
      <td width='92' bgcolor='#FD0000'><div align='center' class='style11'><div align='center'>Reason</div></div></td>
      <td width='106' bgcolor='#FD0000'><div align='center' class='style11'><div align='center'>Status</div></div></td>
      <td width='105' bgcolor='#FD0000'><div align='center' class='style11'><div align='center'>E-mail</div></div></td>
      <td width='98' bgcolor='#FD0000'><div align='center' class='style11'><div align='center'>IP</div></div></td>
      <td width='74' bgcolor='#FD0000'><div align='center' class='style11'><div align='center'>Added</div></div></td>
      <td width='30' bgcolor='#FD0000'><div align='center' class='style11'><div align='center'>G</div></div></td>
      <td width='32' bgcolor='#FD0000'><div align='center' class='style11'><div align='center'>Y</div></div></td>
      <td width='29' bgcolor='#FD0000'><div align='center' class='style11'><div align='center'>P</div></div></td>
    </tr>
    <tr onmouseover=\"this.className='on'\" onmouseout=\"this.className='off'\">
      <td bgcolor='#F2F2F2'><div align='center' class='style11'><div align='center'>";
echo strip_tags($s['name']);
echo "</div></div></td><td bgcolor='#F2F2F2'><div align='center' class='style11'><div align='center'>";
$str = ($s['reson']);

if (strlen($str) <= 6)
{
  echo strip_tags($str);
  echo "";
}
else
{
  $substr = substr($str, 0, 6);
  echo strip_tags($substr);
  echo "...";
  echo "";
}

echo "</div></div></td><td bgcolor='#F2F2F2'><div align='center' class='style11'><div align='center'>";

if ($s['status'] == 0)
{
  print "OK";
}
elseif ($s['status'] > 0)
{
  print "Active";
}

echo "</div></div></td><td bgcolor='#F2F2F2'><div align='center' class='style11'><div align='center'>";
echo strip_tags($s['email']);
echo "</div></div></td><td bgcolor='#F2F2F2'><div align='center' class='style11'><div align='center'>";
echo strip_tags($s['ip']);
echo "</div></div></td><td bgcolor='#F2F2F2'><div align='center' class='style11'><div align='center'>";
echo strip_tags($s['date']);
echo "</div></div></td><td bgcolor='#F2F2F2'><div align='center' class='style11'><div align='center'>
   <img src='google.gif' width='15' height='16' alt='g' /></div></div></td>
    <td bgcolor='#F2F2F2'><div align='center'><img src='yahoo.gif' width='16' height='12' alt='y' /></div></td>
    <td bgcolor='#F2F2F2'><div align='center'><img src='view.gif' width='16' height='16' alt='v' /></div></td>
   </tr>
  </table>
</div>";
}
elseif ($_GET['user'])
{
$sid = ($_GET['user']);
$ss  = mysql_query("SELECT * FROM spammers WHERE sid=$sid");
$r   = mysql_fetch_array($ss);
print "Undergoing Construction.;<br>Looking forward to bring this page back up in a day or two.";
}

?>

Link to comment
Share on other sites

To get all the records, you need to use a loop, you're only getting the first record.

 

You need a "while" loop starting here:

<?php
$sm  = mysql_query("SELECT * FROM spammers ORDER BY $by $ord LIMIT 100");
$s   = mysql_fetch_array($sm);
?>

Something like:

<?php
$q = "SELECT * FROM spammers ORDER BY $by $ord LIMIT 100";
$sm  = mysql_query($q) or die("Problem with the query <pre>$q</pre><br>" . mysql_error());
while ($s   = mysql_fetch_assoc($sm)) {
?>

 

You will have to determine where the end of the loop is by your logic.

 

Ken

 

Link to comment
Share on other sites

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.