Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 06-30-2004, 08:10 PM   #1 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
working with Multi Dimensional Arrays

Example code for a friend that needed a home:
PHP Code:
<?
// first server
$server[0][id]=0;
$server[0][name]="}RwC{ North American CS 1.6";
$server[0][ip]="67.18.240.162";
$server[0][port]="27015";

// second server
$server[1][id]=1;
$server[1][name]="}RwC{ OGL 4.0 Match Server 1.6";
$server[1][ip]="67.18.240.162";
$server[1][port]="27010";

// third server
$server[2][id]=2;
$server[2][name]="Team AEK Server";
$server[2][ip]="64.94.100.152";
$server[2][port]="27015";

// forth server
$server[3][id]=3;
$server[3][name]="-:3C3:- 3astCoast3lite Clan Server";
$server[3][ip]="664.94.238.247";
$server[3][port]="27015";

// fifth server
$server[4][id]=4;
$server[4][name]="Team AEK Scrim Server";
$server[4][ip]="66.150.155.188";
$server[4][port]="27015";

// sixth server
$server[5][id]=5;
$server[5][name]="Newb Playgrounds - @af.mil";
$server[5][ip]="216.52.202.107";
$server[5][port]="27015";

// print drop down
echo "<form name=\"dropMenu\">
    <select name=\"selectThis\" size=\"1\" onChange=\"goThere(this.form);\">"
;

// run a loop to populate with servers
// change status.php to the name of your page
foreach($server as $each){
  echo 
"<option selected value=\"status.php?id=".$each[id]."\">".$each[name]."</option>\n";
}

echo 
"
    </select>
</form>\n"
;

// set the id to 0 if there is not id declared in the url
$id = (($_GET[id])?$_GET[id]:"0";

// print status with the info of the server id populated
printServerStatus($server[$id][ip],
  
$server[$id][port],
  
"images/","#999999","#333333","#aeaeac","#999999");
?>
__________________
Mike
sde is offline   Reply With Quote
Old 06-30-2004, 08:38 PM   #2 (permalink)
Sniper_E
Registered User
 
Join Date: Jun 2004
Posts: 3
Sniper_E is on a distinguished road
Send a message via AIM to Sniper_E
I've added it in my page and get a blank screen.
See if you can see what I may have done wrong.
http://rwc.gameover.com/downloads/new_status.zip
Sniper_E is offline   Reply With Quote
Old 06-30-2004, 09:18 PM   #3 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
maybe try this:
Attached Files
File Type: zip new_status.zip (1.6 KB, 1 views)
__________________
Mike
sde is offline   Reply With Quote
Old 07-02-2004, 04:20 PM   #4 (permalink)
Sniper_E
Registered User
 
Join Date: Jun 2004
Posts: 3
Sniper_E is on a distinguished road
Send a message via AIM to Sniper_E
Still no luck buddy.
I had a guy with our community look at what you sent me and he changed my oringinal file. I sent him http://rwc.gameover.com/downloads/status.zip and he sent me back these changes:


Change:
-------------------------
<?
/*
include("server_status.php");
printServerStatus("67.18.240.162","27015","images/","#999999","#333333","#aeaeac","#999999");
*/
?>

To:
--------------------
<?

include("server_status.php");

// put your information here
// printServerStatus(ip,port,image_path);

// RwC Main
if ($id == 1) { printServerStatus("67.18.240.162","27015","images/","#999999","#333333","#aeaeac","#999999"); }
// RwC OGL
elseif ($id == 2) { printServerStatus("67.18.240.162","27010","images/","#999999","#333333","#aeaeac","#999999"); }
// AEK Main
elseif ($id == 3) { printServerStatus("64.94.100.152","27015","images/","#999999","#333333","#aeaeac","#999999"); }
// OCS
elseif ($id == 4) { printServerStatus("64.27.21.2","27015","images/","#999999","#333333","#aeaeac","#999999"); }
// 3C3
elseif ($id == 5) { printServerStatus("64.94.238.247","27015","images/","#999999","#333333","#aeaeac","#999999"); }
// af.mill
elseif ($id == 6) { printServerStatus("216.52.202.107","27015","images/","#999999","#333333","#aeaeac","#999999"); }

//default server is on when no id specified, so this one points to RwC
else { printServerStatus("67.18.240.162","27015","images/","#999999","#333333","#aeaeac","#999999"); }

?>

and, of course, change:
-----------------------
<option value="">_____ Select A Server _____
<option selected value="http://rwc.gameover.com/status/">}RwC{ North American CS 1.6
<option value="rwcs.php">}RwC{ OGL 4.0 Match Server
<option value="ocs.php">[OCS] West Arena
<option value="aek.php">Team AEK Server
<option value="aeks.php">Team AEK Scrim Server
<option value="3c3.php">-:3C3:- 3astCoast3lite Clan Server
<option value="af.php">Newb Playgrounds - @af.mil

to:
--------------------------
<option value="">_____ Select A Server _____</option>
<option selected value="index.php?id=1">}RwC{ North American CS 1.6</option>
<option value="index.php?id=2">}RwC{ OGL 4.0 Match Server</option>
<option value="index.php?id=3">Team AEK Server</option>
<option value="index.php?id=4">[OCS] West Arena</option>
<option value="index.php?id=5">-:3C3:- 3astCoast3lite Clan Server</option>
<option value="index.php?id=6">Newb Playgrounds - @af.mil</option>


Kind of took a different direction here. I'll have to fine tune this to get exactly what I want, but it will work with your server_status.php

Thank You SDE!
Sniper_E is offline   Reply With Quote
Old 07-02-2004, 05:55 PM   #5 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
sure =) glad u got it working.
__________________
Mike
sde is offline   Reply With Quote
Old 07-07-2004, 04:54 AM   #6 (permalink)
idx
Senior Grasshopper
 
idx's Avatar
 
Join Date: Jun 2003
Location: FL
Posts: 317
idx is on a distinguished road
Not that it matters are this point, but from what I remember in the php docs, it doesn't like bare keynames in arrays like perl does.

eg:

Code:
#perl is ok - any of these work
$FOO{BAR} = 'brarr!';
$FOO{'BAR'} = 'brarr!';
$FOO{"BAR"} = 'brarr!';
PHP Code:
$FOO['BAR'] = 'brarr!';
//no
$FOO[BAR] = 'brarr!'
I think it was something to do with PHP thinking the bare _BAR_ was a defined constant.

??


BTW, good to hear sniper_e got it working, although being obsessive about PHP as I am, that is some horrid code. (what sniper_e posted that is)

-r
idx is offline   Reply With Quote
Old 07-07-2004, 05:17 AM   #7 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
i wrote most of that (except the madquery class which is definately pretty hardcore), except my site is all integrated into mysql. we had to find a nicer way for him to display multiple server without mysql.

http://ocsclan.com/status.php?sid=15
__________________
Mike
sde is offline   Reply With Quote
Old 07-11-2004, 01:43 PM   #8 (permalink)
Sniper_E
Registered User
 
Join Date: Jun 2004
Posts: 3
Sniper_E is on a distinguished road
Send a message via AIM to Sniper_E
I found out later that dan had something turned off in the php.ini on our server. Your script would have prob worked. But, I'm pretty happy with what I have now: http://rwc.gameover.com/status/index.php?id=5

You can grab that menu from me that I made if you like it.
It's in here: http://rwc.gameover.com/downloads/status.zip
I think it's an improvement to my page.

You guys are awesome! I wish I had some of that knowlege....
Sniper_E is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Arrays, the 'right' way. Mr.Anderson Standard C, C++ 10 10-05-2004 06:00 AM
sorting multi dimensional arrays sde PHP 4 10-01-2003 05:52 PM


All times are GMT -8. The time now is 05:02 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting