Jump to content

Recommended Posts

If I open this code in my webbrowser it always get stuck. :S

all the other pages don't

 

it did work until I added $cattop['ammount']

 

<?php
#leden
#gedichten
#gedichten / lid
#top 10 posters
#top 10 categories
#...

/* DATABASE SETTINGS */

$query = "SELECT COUNT(user_id) FROM users";
$result = mysql_query($query);
list($users) = mysql_fetch_row($result);  # Number of users

$query = "SELECT COUNT(poem_id) FROM poems";
$result = mysql_query($query);
list($poems) = mysql_fetch_row($result);  #  Number of poems

$ppu = $poems / $users;                   # $ppu = $poems per user

$query = " SELECT user_name, ammount, (
SELECT count( * ) + 1
FROM users b
WHERE a.ammount < b.ammount
) AS rank
FROM users a
ORDER BY rank
LIMIT 0 , 10 ";
$ress = mysql_query($query);
while($usertop = mysql_fetch_array($ress)) {

$query = " SELECT category_name, ammount, (
SELECT count( * ) + 1
FROM categories b
WHERE a.ammount < b.ammount
) AS rank
FROM categories a
ORDER BY rank
LIMIT 0 , 10 ";
$res = mysql_query($query);
while($cattop = mysql_fetch_array($res)) {
?>
<html dir="ltr">
    <head>
        <title>STATISTIEKEN</title>
        <link href="../../standard.css" type="text/css" rel="stylesheet" />
<link href='dichtkunst.css' type='text/css' rel="stylesheet" />
    </head>
    <body>
        <table class="look" height="100%" width="100%" border="1">
            <tbody>
                <tr>
                    <td width="10%" height="100%"><iframe class="frames" src="../../functieknoppen/functieknoppendichtkunst.htm" frameborder="0" width="100%" height="100%" scrolling="no"></iframe>
                    </td>
                    <td><center>
<table border="0"><tr><td colspan="2"><b>STATISTIEKEN</b></td></tr>
<tr><td>Aantal gebruikers:</td><td><b><?php echo $users; ?></b></td></tr>
<tr><td>Aantal gedichten:</td><td><b><?php echo $poems; ?></b></td></tr>
<tr><td>Aantal gedichten per gebruiker:</td><td><b><?php echo $ppu; ?></b></td></tr>
<tr><td>Top 10 gebruikers:</td><td><b><?php echo "{$usertop['rank']} | {$usertop['user_name']} | {$usertop['ammount']}"; ?>
</b></td></tr>
<tr><td>Top 10 categorien:</td><td><b><?php echo "{$cattop['rank']} | {$cattop['category_name']} | {$cattop['ammount']}"; ?></b></td></tr>
</table>
<?php
}
}
?>
                    </center></td>
                </tr>
            </tbody>
        </table>
    </body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/148371-stats-prob/
Share on other sites

sorry I'm just getting irritated about that st*pid bug. it wasn't the meaning to react that way on u :),

The problem is just if I use code 1 for the site (without the cattegories)

it works fast

 

if I use code 2 with the catteogries, the browser get stuck and I have to end the proces.

I want to know what the source from that bug is and I wished somebody could help me.

 

code 1:

<?php
#leden
#gedichten
#gedichten / lid
#top 10 posters
#top 10 categories
#...

/*DATABASE SETTINGS */

$query = "SELECT COUNT(user_id) FROM users";
$result = mysql_query($query);
list($users) = mysql_fetch_row($result);  # Number of users

$query = "SELECT COUNT(poem_id) FROM poems";
$result = mysql_query($query);
list($poems) = mysql_fetch_row($result);  #  Number of poems

$ppu = ($poems / $users);                   # $ppu = $poems per user

$query = " SELECT user_name, ammount, (
SELECT count( * ) + 1
FROM users b
WHERE a.ammount < b.ammount
) AS rank
FROM users a
ORDER BY rank
LIMIT 0 , 10 ";
$ress = mysql_query($query);
while($usertop = mysql_fetch_array($ress)) {

?>
<html dir="ltr">
    <head>
        <title>STATISTIEKEN</title>
        <link href="../../standard.css" type="text/css" rel="stylesheet" />
<link href='dichtkunst.css' type='text/css' rel="stylesheet" />
    </head>
    <body>
        <table class="look" height="100%" width="100%" border="1">
            <tbody>
                <tr>
                    <td width="10%" height="100%"><iframe class="frames" src="../../functieknoppen/functieknoppendichtkunst.htm" frameborder="0" width="100%" height="100%" scrolling="no"></iframe>
                    </td>
                    <td><center>
<table border="0"><tr><td colspan="2"><b>STATISTIEKEN</b></td></tr>
<tr><td>Aantal gebruikers:</td><td><b><?php echo $users; ?></b></td></tr>
<tr><td>Aantal gedichten:</td><td><b><?php echo $poems; ?></b></td></tr>
<tr><td>Aantal gedichten per gebruiker:</td><td><b><?php echo $ppu; ?></b></td></tr>
<tr><td>Top 10 gebruikers:</td><td><b><?php echo "{$usertop['rank']} | {$usertop['user_name']} | {$usertop['ammount']}"; ?>
</b></td></tr>
</table>
<?php
}
?>
                    </center></td>
                </tr>
            </tbody>
        </table>
    </body>
</html>

 

code 2:

<?php
#leden
#gedichten
#gedichten / lid
#top 10 posters
#top 10 categories
#...

/*DATABASE SETTINGS */

$query = "SELECT COUNT(user_id) FROM users";
$result = mysql_query($query);
list($users) = mysql_fetch_row($result);  # Number of users

$query = "SELECT COUNT(poem_id) FROM poems";
$result = mysql_query($query);
list($poems) = mysql_fetch_row($result);  #  Number of poems

$ppu = ($poems / $users);                   # $ppu = $poems per user

$query = " SELECT user_name, ammount, (
SELECT count( * ) + 1
FROM users b
WHERE a.ammount < b.ammount
) AS rank
FROM users a
ORDER BY rank
LIMIT 0 , 10 ";
$ress = mysql_query($query);
while($usertop = mysql_fetch_array($ress)) {

$query = " SELECT category_name, ammount, (
SELECT count( * ) + 1
FROM categories b
WHERE a.ammount < b.ammount
) AS rank
FROM categories a
ORDER BY rank
LIMIT 0 , 10 ";
$res = mysql_query($query);
while($cattop = mysql_fetch_array($res)) {
?>
<html dir="ltr">
    <head>
        <title>STATISTIEKEN</title>
        <link href="../../standard.css" type="text/css" rel="stylesheet" />
<link href='dichtkunst.css' type='text/css' rel="stylesheet" />
    </head>
    <body>
        <table class="look" height="100%" width="100%" border="1">
            <tbody>
                <tr>
                    <td width="10%" height="100%"><iframe class="frames" src="../../functieknoppen/functieknoppendichtkunst.htm" frameborder="0" width="100%" height="100%" scrolling="no"></iframe>
                    </td>
                    <td><center>
<table border="0"><tr><td colspan="2"><b>STATISTIEKEN</b></td></tr>
<tr><td>Aantal gebruikers:</td><td><b><?php echo $users; ?></b></td></tr>
<tr><td>Aantal gedichten:</td><td><b><?php echo $poems; ?></b></td></tr>
<tr><td>Aantal gedichten per gebruiker:</td><td><b><?php echo $ppu; ?></b></td></tr>
<tr><td>Top 10 gebruikers:</td><td><b><?php echo "{$usertop['rank']} | {$usertop['user_name']} | {$usertop['ammount']}"; ?>
</b></td></tr>
<tr><td>Top 10 categorien:</td><td><b><?php echo "{$cattop['rank']} | {$cattop['category_name']} | {$cattop['ammount']}"; ?></b></td></tr>
</table>
<?php
}
}
?>
                    </center></td>
                </tr>
            </tbody>
        </table>
    </body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/148371-stats-prob/#findComment-778967
Share on other sites

does this do anythink might not just a go sorry no good at joins.

<?php
$query = " SELECT b.user_name, a.ammount, (
SELECT count( * ) + 1
FROM a.users , b.user_name
WHERE a.ammount < b.ammount
) AS rank ORDER BY rank
LIMIT 0 , 10 ";
$ress = mysql_query($query);
?>

Link to comment
https://forums.phpfreaks.com/topic/148371-stats-prob/#findComment-778975
Share on other sites

Might be way off here but do you really need to run that query inside the while loop?

 

<?php

$query = " SELECT category_name, ammount, (
SELECT count( * ) + 1
FROM categories b
WHERE a.ammount < b.ammount
) AS rank
FROM categories a
ORDER BY rank
LIMIT 0 , 10 ";

?>

 

It doesn't seem to draw any information from the other query (or it seems to me). So your running it every loop of the above while loop when it looks like it doesn't have to (again I maybe way off, if so sorry).

Link to comment
https://forums.phpfreaks.com/topic/148371-stats-prob/#findComment-778984
Share on other sites

Okay, lets say it works,

 

I still have one problem.

the statistic page generates a page wich lists all top 10 users, but there is one problem.

IF you visit the site, you will see it  http://4ade.uuuq.com/statistics.php

 

the problem is that I generate a while loop in a table, the while loop orders all the top ten users,

and should place them in a next row in the same table, but it generates it in a next row in a new table.

 

how can I solve this?

this is the main code:

<?php
$query = "SELECT COUNT(user_id) FROM users";
$result = mysql_query($query);
list($users) = mysql_fetch_row($result);  # Number of users

$query = "SELECT COUNT(poem_id) FROM poems";
$result = mysql_query($query);
list($poems) = mysql_fetch_row($result);  #  Number of poems

$ppu = ($poems / $users);                   # $ppu = $poems per user

$query = " SELECT user_name, ammount, (
SELECT count( * ) + 1
FROM users b
WHERE a.ammount < b.ammount
) AS rank
FROM users a
ORDER BY rank
LIMIT 0 , 10 ";
$ress = mysql_query($query);
while($usertop = mysql_fetch_array($ress)) {
?>

<table border="0"><tr><td colspan="2"><b>STATISTICS</b></td></tr>
<tr><td>Ammount of users:</td><td><b><?php echo $users; ?></b></td></tr>
<tr><td>Ammount of poems:</td><td><b><?php echo $poems; ?></b></td></tr>
<tr><td>Ammount poems / user:</td><td><b><?php echo $ppu; ?></b></td></tr>
<tr><td>Top 10 users:</td><td><b><?php echo "{$usertop['rank']} | {$usertop['user_name']} | {$usertop['ammount']}"; ?>
</b></td></tr>
</table><?php } ?>

Link to comment
https://forums.phpfreaks.com/topic/148371-stats-prob/#findComment-780571
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.