Ravens PHP Scripts: Forums
 

 

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



Joined: Oct 09, 2006
Posts: 413
Location: UK

PostPosted: Mon Nov 27, 2006 12:57 pm Reply with quote

We have a Birthdays Block on our RN76 gaming clan site. Pretty standard format, it drags user dates from the db and posts them in a block. Also it drags 'clan' birthdays and displays them in the same manner.
We also have a system of ranks for differant member levels, all stored in another table.

Im not a programmer, nor a linguist, but this is what i want to do....

I want the same data to be displayed, but i want it to exclude members that are of a certain rank.

im sure its just a new line to be added, but i dont know whereabouts in the script, nor do i know how to write it.

Any ideas guys?
 
View user's profile Send private message Visit poster's website AIM Address
gregexp
The Mouse Is Extension Of Arm



Joined: Feb 21, 2006
Posts: 1497
Location: In front of a screen....HELP! lol

PostPosted: Mon Nov 27, 2006 5:44 pm Reply with quote

now youll need to figure out how to define if they are of the ranks you dont want to see, then create an if statement then output what you want if they are that rank and what you want if they are not.

_________________
For those who stand shall NEVER fall and those who fall shall RISE once more!! 
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
wiz







PostPosted: Mon Nov 27, 2006 11:40 pm Reply with quote

well i dont know php all that well, especially sql commands.
We have one table that defines the ranks (clan_ranks.sql). Our older members like founders and stuff,who have since left , we like to keep on record; but dont want them to be displayed in the birthdays block. Those ppl for the purposes of the clan are defined as the variable $Vet.
I understand the If's and ignores etc, but havent a clue. How to actually build the line, because i cant see it used anywhere else really. After many hours of scrolling thru scripts i tend to go blind Smile
 
Gremmie
Former Moderator in Good Standing



Joined: Apr 06, 2006
Posts: 2415
Location: Iowa, USA

PostPosted: Tue Nov 28, 2006 10:16 am Reply with quote

Its kind of hard to help without seeing the code for the block.

_________________
Only registered users can see links on this board! Get registered or login! - An Event Calendar for PHP-Nuke
Only registered users can see links on this board! Get registered or login! - A Google Maps Nuke Module 
View user's profile Send private message
wiz







PostPosted: Tue Nov 28, 2006 10:19 am Reply with quote

well, i would but sentinel blocks me if i post script
 
evaders99
Former Moderator in Good Standing



Joined: Apr 30, 2004
Posts: 3221

PostPosted: Tue Nov 28, 2006 3:51 pm Reply with quote

Post a link to a txt file of your code

_________________
- Only registered users can see links on this board! Get registered or login! -

Need help? Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
gregexp







PostPosted: Tue Nov 28, 2006 7:46 pm Reply with quote

Sorry Evaders, was typing all this out while you posted, Left open while I took a little nap too lol.

Ahh, rename the file with the .txt ext, then send us a direct link, none of the code will be processesed so we will be able to help in this manner. Also post the structure of the table that you say tells if they are members of such and such.
Also post what values would be associated with what:

For example

Table_name:
Structure:
uid
date_joined
ip
rank.

then I would say for example, that uid is the user_id from the nuke_users table,
date joined and ip are self explainatory, rank is 1 for private 2 for seargeant, 3 for ensign, 4 for captain, 5 for General, This is an example. Now we know all we need to know on how to CHECK that the user is who he says he is, also how to check the Rank to validate the permission.

So first part would be a check system to make sure they are logged in, and it is all correct.

//mainfile defines this function to tell if the user is a user.Returns one for true, and 0 for false, we want to make sure its true and leave NO room for inconsistancy.
$uchk=(is_user($user));

If($uchk==1){
if (!is_array($user)) {
$user = base64_decode($user);
$user = addslashes($user);
$user = explode(":", $user);
}
$uid = $user[0];
$pwd = $user[2];
$uid = intval($uid);
}

//Now I have the uid
//Now we will select the Rank needed.
$sql='SELECT Rank from Table_name WHERE uid='.$uid.'';
$result=$db->sql_query($sql);//This runs the query.
$row=$db->sql_fetchrow($result);
$trank=$row['0'];//It returns an array so lets Get the actual result, to see the array to help you better understand it when running this: print_r($row);// print_readable is how I remember it.

//Now we setup an array of Ranks That we dont want to see this:
$ranks_notview=array(3,4,5);//From our previous example, noone but non officers and the General should be able to see this.

if(!in_array($trank,$ranks_notview)){
//Basically, if THERE rank is not in the array of ranks that cannot view this.! is used to declare a false return.
//put code here for them to see
}else{
//Put code here for the people not able to view something here or leave it blank
//I always put something here like, hey you cannot view this and heres why:
}

Just so you know, // Tells php Not to process that line, so it can be left saying anything you want, and php will not even look at it. That is why you see all my comments like // coment, If this was a php script, It would process just the way it is.
 
wiz







PostPosted: Wed Nov 29, 2006 11:15 am Reply with quote

ok guys This is a link to the text version of the block..

Only registered users can see links on this board! Get registered or login!

The variable i want to exclude is $isvet. From the table sas_ranks.

Hope this helps

p.s i still want the excluded rank to view, just i dont want there birthdays in the block.
 
wiz







PostPosted: Tue Dec 12, 2006 9:19 pm Reply with quote

any ideas?
 
Gremmie







PostPosted: Wed Dec 13, 2006 8:30 am Reply with quote

Post the structure of your sas_members table and any rank table you have. I suspect you could just modify the SQL query to exclude veterans without changing any other code.
 
wiz







PostPosted: Wed Dec 13, 2006 12:30 pm Reply with quote

table SAS_ranks example used for $vet

ranid 1
ranname veteran
ranimage image/path
rantypeid 6

but pages that we require the use of the ranks, for either allowing access or blocking access, all call an include...
include rankorder.php

all our ranks are defined for eg $isvet
then the file just has the various requirements to view certain modules/etc...
$!!canviewmembersdocs !!= $!!isMember;(tip,remove all !!)
 
Gremmie







PostPosted: Wed Dec 13, 2006 1:38 pm Reply with quote

Please post the structure of your tables...use phpmyAdmin or something. I need to see how the tables relate to each other.
 
wiz







PostPosted: Sun Jan 07, 2007 10:11 am Reply with quote

Sorry for the delay in getting back to you gremmie. Do you want me to post, the whole db structure? or just that table? Either way, how would i do that? i only see an option to 'print view' the structure. Embarassed
 
Gremmie







PostPosted: Sun Jan 07, 2007 11:46 am Reply with quote

Export the table as SQL (text) and post that. Do that for your members table and any rank tables you have.
 
wiz







PostPosted: Wed Jan 10, 2007 9:33 am Reply with quote

ok ive been thinking around this problem. Maybe theres another way. Lets say in the birthdays block, i dont want to display everybodys birthday that it picks during the sql query. So i need some kind of variable to distinguish the ones i do, from the one i dont.
So in theory i would need to run a seperate query?
Something like..
sql = select from table (_ranks).$rantypeid;
if $rantypeid = 4....

would that be closer to the mark? If so i could then let it display anyone who is classed as rank4 and nobody else, the type i want to exclude would be rank5, so would that cause it to exclude 3,2 and 1 also?

Ive been cheating a little, by scouring for a similar script for another application somewhere, and trying to copy the script. No such solution so far
Cheers
WIZ
 
Gremmie







PostPosted: Wed Jan 10, 2007 11:22 am Reply with quote

Well I was thinking along the lines of modifying your existing queries by saying things like "SELECT ... FROM .... WHERE rank != veteran"
 
wiz







PostPosted: Wed Jan 10, 2007 11:59 am Reply with quote

would it be easier to exclude just one type of rank, rather than include several?
ie if the rantypeid = 5 then skip this part of the script
 
wiz







PostPosted: Sat Jan 20, 2007 7:46 pm Reply with quote

Code:
$sql = "SELECT 1 as ind, DAYOFMONTH(`memBirthdate`) day, MONTH(`memBirthdate`) month, YEAR(`memBirthdate`) year, `sas_members`.* FROM `sas_members`('ranId') FROM 'sas_ranks' WHERE ranId <99>";

$sql .= " WHERE ((MONTH(`memBirthdate`) = ".date(m)." AND DAYOFMONTH(`memBirthdate`) > ".date(j).") OR (MONTH(`memBirthdate`) > ".date(m)." )) AND (YEAR(`memBirthdate`)>0)";
$sql .= " UNION SELECT 2 as ind, DAYOFMONTH(`memBirthdate`) day, MONTH(`memBirthdate`) month, YEAR(`memBirthdate`) year, `sas_members` .* FROM `sas_members`";
$sql .= " WHERE (MONTH(`memBirthdate`) < ".date(m)." ) AND (YEAR(`memBirthdate`)>0)";
$sql .= " ORDER BY ind, MONTH(`memBirthdate`), DAYOFMONTH(`memBirthdate`)";
$sql .= " LIMIT 0, 3";
$rs = $db->sql_query($sql);
$row = $db->sql_fetchrow($rs);
if ($row)
{
        $birthday .= "<p class=\"content\">";
        $birthday .= "Coming Birthdays<br><br>";
        while ($row)
        {
                $id = $row[memId];
                $memName = $row[memName];
                $day = $row[day];
                $month = $row[month];
                $year = $row[year];
               
                $sum = 0;
                if  ( date(m) - $month > 0 ) $sum = 1;
                $dif = date(Y) - $year + $sum;
            $memBirthdate = $day."-".$month;
               
                $birthday .= "<a href=\"modules.php?name=Members&members_set=details&id=".$id."\">".$memName."</a>: ".$dif." on ".$memBirthdate."<br>";
                $row = $db->sql_fetchrow($rs);
        }
        $birthday .= "</p>";


Thats what i have so far, but the block doesnt show at all. The idea is to show all member birthdays from the table 'sas_members' except those that have the 'ranId' of 99 from the table 'sas_ranks'
 
Gremmie







PostPosted: Sat Jan 20, 2007 8:56 pm Reply with quote

You might want to read up on blocks in the PHP-Nuke How-To. The HTML that you want to appear in the block must be assigned to a variable called $content.
 
wiz







PostPosted: Sat Jan 20, 2007 11:07 pm Reply with quote

that is not the whole code for the block. as you will have seen in the link i posted earlier in the topic. but just the part that ive added the bit to exclude the 'vets'
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

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 ©