Jump to content


Photo

Mysql resoult with another connect and resoult inside it! help


  • Please log in to reply
No replies to this topic

#1 mycosis

mycosis
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 24 September 2006 - 10:50 PM

<?
include("db.inc.php");
//stat
mysql_connect($db,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM ipstats";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();

$i=0;
while ($i < $num) {

$id=mysql_result($result,$i,"id");
$ip=mysql_result($result,$i,"ip");
$on=mysql_result($result,$i,"online");
$lu=mysql_result($result,$i,"last_used");

echo"<table width='600' border='1' cellspacing='0' cellpadding='0'>
  <tr>
    <td width='200' align='left' valign='top'>ID: $id<br />
IP: $ip<br />
$online<br />
Sisst sett: $lu</td>

    <td width='400' align='left' valign='top'><table width='100%' border='0' cellspacing='0' cellpadding='0'>";
// Slutt stat
// Start nickstat
mysql_connect($db,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
query
$query2="SELECT * 
FROM `ipstats_nicks` 
WHERE ipstats_id =$id
ORDER BY nick ASC";
$result2=mysql_query($query2);
$num2=mysql_numrows($result2);
mysql_close();
echo"<tr>
        <td>Nick:</td>
        <td>Brukt:</td>
        <td>Online:</td>
        <td>Sisst brukt:</td>
    </tr>";
while ($i2 < $num2) {
$nick=mysql_result($result2,$i2,"nick");
$brukt=mysql_result($result2,$i2,"used_times");
$onnick=mysql_result($result2,$i2,"online");
$lunick=mysql_result($result2,$i2,"last_used");

echo" <tr>
        <td>$nick</td>
        <td>$brukt gang(er) </td>
        <td>$onnick</td>
        <td>$lunick</td>
      </tr>";
$i2++;
}
// Slutt nickstat
// Start stat
echo"</table>
    </td>
  </tr>
</table>
<br />
<br />";
$i++;
}
?>

It is two record in the DB (see here: http://elmannen.net/dc%20stats/), but the second onne isn't getting any result. why?
I think its because $query2 and those come again at second loop...
PLZ help, how can i get it going?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users