Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules
Author Message
Donovan
Client



Joined: Oct 07, 2003
Posts: 735
Location: Ohio

PostPosted: Sun Oct 24, 2004 11:19 am Reply with quote

I installed a module called Clan_Nuke on my site and am currently heavily modifying the roster part to it. I have added tables such as:

roster_profiles
roster_unit
roster_awards

and modified roster_members and added some fields.

You can see it here. [ Only registered users can see links on this board! Get registered or login! ]

When you view my profile you see I belong to 2nd Platoon which in the roster_units table is unit_id = 3

unit_id = 1 is Headquarters
unit_id = 2 is 1st Platoon
unit_id = 3 is 2nd Platoon
unit_id = 4 is 3rd Platoon

When you click on my unit link it sends me to 1st Platoon. My uniqueid in the roster_members and roster_profile table is 6.

I have a disconnect I can't seem to understand.

When I click on a member it loads thier correct profile to the rosterprofile page. One thing I can't figure out is the original authors use of the variable $handlename. It isn't referenced in the index.php, nor in the clannuke/functions.php

Here is the part of my index.php where the roster rank is loaded:

Code:
$result = $db->sql_query("SELECT `rankname` FROM `roster_ranks` ORDER BY `uniqueid`");

   while ( $row = $db->sql_fetchrow($result) ) {
      $rankname = $row["rankname"];
        $flag=0;
      $result1 = $db->sql_query("SELECT `u_handle`, `uniqueid` FROM `roster_members` WHERE `u_rank`='$rankname'");
        if (!$result1) {
          echo("<p>Error performing query: " . mysql_error() . "</p>");
          exit();
        }


And then it loads the names

Code:
$result = $db->sql_query("SELECT `u_handle`, `uniqueid`$tables FROM `roster_members` WHERE `u_rank`='$rankname' ORDER BY unit");


Here is the parts of my rosterprofile to get everybodies info:

Code:
$result = $db->sql_query("SELECT * FROM roster_profile WHERE uniqueid ='$handlename'");

$info = $db->sql_fetchrow($result);
    if (!$result) {
    echo("<p>Error performing query: " . mysql_error() . "</p>");
    exit();
    }


I created the second results1 in an attempt to load the correct unit every body is assigned to but is isn't working. Again it is this use of $handlename that is confusing. Do I declare some other variable to use to pull units from the units table? If so how?

Code:
$result1 = $db->sql_query("SELECT * FROM roster_ranks a JOIN roster_profile b JOIN roster_units c WHERE b.uniqueid='$handlename' AND a.rank_id = b.rank_id AND b.unit_id = c.unit_id");

$info1 = $db->sql_fetchrow($result1);
    if (!$result) {
    echo("<p>Error performing query: " . mysql_error() . "</p>");
    exit();
    }


I am getting this done slow but sure, but need some assistance understanding the use of these variables and how they connect.

Finnaly here is my link in rosterprofile that displays the unit:

Code:
<td width=\"15%\" align=\"right\">"

  . "                     <b><font color=\"#660033\">Combat Unit:</font></b>"
  . "                  </td>"
  . "                  <td width=\"44%\" colspan=\"3\">"
  . "                     <p class=\"content\"><a href=\"modules.php?name=roster&file=unitprofile&uniqueid=$uid\" title=\"\">$info1[unit_name]</a>"
  . "                  </td>"


I have tried $uid, $Handlename, $uniqueid, but nothing seems to work here. I am missing something here and I just can't see it.

In the end I may outsource the creation of an admin page to somebody. I have funds reserved for this if needed.

Thanks for your time.

-Donovan
 
View user's profile Send private message Visit poster's website ICQ Number
Donovan







PostPosted: Sun Oct 24, 2004 12:39 pm Reply with quote

I meant to post this in the PHP forum.

O_o
 
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Sun Oct 24, 2004 3:46 pm Reply with quote

You did but I moved it because it is a nuke module, correct?
 
View user's profile Send private message
Donovan







PostPosted: Sun Oct 24, 2004 5:02 pm Reply with quote

Yes it is a Nuke module. Any help is appreciated.
 
Donovan







PostPosted: Mon Oct 25, 2004 9:18 am Reply with quote

I know I'm being impatient but let me clarify what I'm trying to do.

From my index.php on the roster I click here and pull up a profile:

Code:
while ( $row = $db->sql_fetchrow($result1) ) {

          $hname = $row["u_handle"];
          $uid = $row["uniqueid"];
          echo ("<a href=\"modules.php?name=$module_name&file=rosterprofile&handlename=$uid\">$hname</a><br>");


With this statment I pull the correct profile for a member

Code:
$result = $db->sql_query("SELECT * FROM roster_profile WHERE uniqueid ='$handlename'");

$info = $db->sql_fetchrow($result);
    if (!$result) {
    echo("<p>Error performing query: " . mysql_error() . "</p>");
    exit();
    }


Now I need to pull the correct unit profile for that member, but don't understand the use of $handlename

I am guessing it is something like the following:

Code:
$result = $db->sql_query("SELECT * FROM roster_units a JOIN roster_profile b Where a.unit_id ='$unitname'");

$info = $db->sql_fetchrow($result);
    if (!$result) {
    echo("<p>Error performing query: " . mysql_error() . "</p>");
    exit();
    }


with a link on the rosterprofile page

Code:
href=\"modules.php?name=roster&file=unitprofile&uniqueid=$unitname\" title=\"\">$info1[unit_name]</a>"


but this is not working.
 
Raven







PostPosted: Mon Oct 25, 2004 10:29 am Reply with quote

In block 1 (code above) you set up multiple links with a key/value pair of handlename/uid. So that's all that gets passed to your next block.

In block 2 you use handlename/uid to pull records from roster_file.

Since I don't know the schemas for the tables, I can't help much more, but I would suggest NOT using joins if you don't have to and normally you don't. I'm a DBA so it isn't because I don't understand them Wink. Work the problem out, first, w/o joins, then go back and see if they improve performance. Unless they are very large tables, you won't see a noticable difference.

When you say you can't understand the use of $handlename, $handlename is passed via the GET HTTP Method and becomes available via a $_GET['handlename'] call.
 
Donovan







PostPosted: Mon Oct 25, 2004 12:11 pm Reply with quote

Thanks for the reply. Here is the schema. It is probably a little confusing since I started with somebody elses tables and started adding and deleting what I wanted all the while trying to keep the original roster still working. The use of u_handle and uniqueid everywhere was really odd.

I also have other tables like roster_awards, and probably more, but if I get this basic concept down of these key/value pair with handlename and uid I can apply that to my other tables and php pages. I was going to have individual $result = statments and name them $result1 and $result2 and such but tried it with JOIN instead.

Anymore help you can give me to set me on the right track would be most helpful. I have looked numerous times for a reference to $handlename and have come up blank as well as a $_GET statement


#
# Table structure for table `roster_members`
#
u_handle text NOT NULL,
u_pass text NOT NULL,
u_rank text NOT NULL,
uniqueid tinyint(4) NOT NULL auto_increment,
KEY uniqueid (uniqueid)

#
# Table structure for table `roster_profile`
#
u_handle text NOT NULL,
rank_id tinyint(4) NOT NULL default '0',
uniqueid tinyint(4) NOT NULL auto_increment,
unit_id tinyint(4) NOT NULL default '0',
award_id tinyint(4) NOT NULL default '0',
KEY uniqueid (uniqueid),

#
# Table structure for table `roster_ranks`
#
rankname text NOT NULL,
uniqueid tinyint(4) NOT NULL auto_increment,
rank_id tinyint(4) NOT NULL default '0',
rank_image varchar(255) NOT NULL default '',
KEY uniqueid (uniqueid)

#
# Table structure for table `roster_units`
#
unit_id tinyint(4) NOT NULL default '0',
unit_name varchar(255) NOT NULL default '',
etc
etd
PRIMARY KEY (unit_id),
 
Raven







PostPosted: Mon Oct 25, 2004 3:31 pm Reply with quote

I explained where $handlename is comin from: your fist block - it's passed in the URL
Code:
echo ("<a href=\"modules.php?name=$module_name&file=rosterprofile&handlename=$uid\">$hname</a><br>");


&handlename=$uid


If your setup has register_global set to ON then the value is immediately available without using the $_GET or $_GLOBALS array.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©