Jump to content

Mysql resoult with another connect and resoult inside it! help


mycosis

Recommended Posts

[code]<?
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++;
}
?>[/code]

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