Lost Password?


Go Back   CodeCall Programming Forum > Web Development Forum > PHP Forum

PHP Forum Use this forum to discuss all aspects of PHP Development. PHP is a server-side, cross-platform, HTML embedded scripting language that lets you create dynamic web pages.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #11 (permalink)  
Old 04-23-2008, 02:46 PM
Whitey's Avatar   
Whitey Whitey is offline
Programming Professional
 
Join Date: Feb 2008
Location: Loveland, Colorado
Posts: 225
Rep Power: 6
Whitey has a spectacular aura aboutWhitey has a spectacular aura aboutWhitey has a spectacular aura about
Send a message via AIM to Whitey Send a message via MSN to Whitey Send a message via Skype™ to Whitey
Default Re: Function Help

Well the system i have made is you can add new main games.. so i am trying to make it generate on its own..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 04-23-2008, 03:02 PM
John's Avatar   
John John is online now
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,432
Last Blog:
Google Web Toolkit
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default Re: Function Help

Exactley. Hence the for loop:
PHP Code:
for($i 0$i <= $maxi++)
{
    
$q2 "SELECT `id` FROM `Members` WHERE `maingame` = '".$row[$i]."'";
    
$result2 mysql_query($q2);
    echo 
$row[$i] . "-->" mysql_num_rows($result);

$row[$i] is the game id (in the previous post I statically set $row[$i] = 1). However, $row is an array of game id's which are dynamically generated upon request. The for loop circulates through the entire array of game id's and calculates the amount of members have have the game id, $row[$i], as their main game.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 04-23-2008, 09:00 PM
Whitey's Avatar   
Whitey Whitey is offline
Programming Professional
 
Join Date: Feb 2008
Location: Loveland, Colorado
Posts: 225
Rep Power: 6
Whitey has a spectacular aura aboutWhitey has a spectacular aura aboutWhitey has a spectacular aura about
Send a message via AIM to Whitey Send a message via MSN to Whitey Send a message via Skype™ to Whitey
Default Re: Function Help

PHP Code:
$q1 "SELECT `id` FROM `{$dbprefix}GamesPlayed`";
$result mysql_query($q1);
$row mysql_fetch_array($result);
$max count($row);

for(
$i 0$i <= $maxi++)
{
    
$q2 "SELECT `id` FROM `{$dbprefix}members` WHERE `maingame` = '".$row[$i]."'";
    
$result2 mysql_query($q2);
    echo 
$row[$i]; 
    echo 
"-->"
    echo 
mysql_num_rows($result2);

This wouldn't work..
I tried it in the sql and it came up blank as well..
why would we select Id from members? the maingame is indeed a number
and we need to set the maingame = the id from gamesplayed..
see it gets confusing..

when i put this in my phpmyadmin
SELECT maingame, COUNT('1') FROM {$dbprefix}members GROUP BY maingame

it comes up with 5
wich is correct.. so my function has the right format is just has an error somewhere!

Last edited by Whitey; 04-23-2008 at 09:05 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #14 (permalink)  
Old 04-23-2008, 10:16 PM
John's Avatar   
John John is online now
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,432
Last Blog:
Google Web Toolkit
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default Re: Function Help

Quote:
Originally Posted by Whitey View Post
why would we select Id from members? the maingame is indeed a number
and we need to set the maingame = the id from gamesplayed..
see it gets confusing..
You can select anything from members, you just need to select something to count. If you want to PM me your SQL dump I can play with it locally. I'm sure I can come up with a solution.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #15 (permalink)  
Old 04-24-2008, 12:05 AM
Whitey's Avatar   
Whitey Whitey is offline
Programming Professional
 
Join Date: Feb 2008
Location: Loveland, Colorado
Posts: 225
Rep Power: 6
Whitey has a spectacular aura aboutWhitey has a spectacular aura aboutWhitey has a spectacular aura about
Send a message via AIM to Whitey Send a message via MSN to Whitey Send a message via Skype™ to Whitey
Default Re: Function Help

my function updated..
it shows the games.. but the count is messed up.

it comes out for every game 1 as the count.
here is the code
PHP Code:
function getGameStats()
{
global 
$dbprefix;
$query "SELECT * FROM {$dbprefix}gamesplayed";
$result mysql_query($query)
     or die(
mysql_error());
echo 
'<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>'
;
for (
$i 0$i mysql_num_rows($result); $i $i 1)
{
    
$gamepic mysql_result($result$i"gamepic");
    
$gamename mysql_result($result$i"gamename");
    
$id mysql_result($result$i"ID");
        
$query1 "SELECT 'id' FROM {$dbprefix}members WHERE maingame = $id";
        
$result1 mysql_query($query1) or die(mysql_error());
            
$stat mysql_num_rows($result1);
            
$stat count($stat);
                echo (
"<td><div align='center'><img src='$gamepic' alt='$gamename'> $stat</div></td>");
        
}
echo 
'  </tr>
</table>'
;

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Inline function Chinmoy C Tutorials 1 04-07-2008 04:13 PM
using Template function Chinmoy C Tutorials 4 04-03-2008 05:16 AM
function pointer Chinmoy C Tutorials 0 03-19-2008 01:52 AM
SecurityAudit vinay Visual Basic Programming 27 01-07-2008 01:14 PM


All times are GMT -5. The time now is 12:40 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 97%

Ads