Jump to content

tcollie

Members
  • Posts

    45
  • Joined

  • Last visited

    Never

Everything posted by tcollie

  1. Okay, I've created a function to calculate the max amount that can be purchased for a market system. It looks like this: function market_max($cash) { include('includes/_config.php'); $max['product_01'] = $cash/$config['product_01']; return $max; } And my includes/_config.php code: $config['product_01'] = 1; And my script: $cash = 1000; market_max($cash); print_r($max); This doesn't output anything. But if I just code it outside the function like this, it works: include('includes/_config.php'); $cash = 1000; $max['product_01'] = $cash/$config['product_01']; print_r($max); Output: Array ( [product_01] => 1000 ) Where am I going wrong???
  2. I agree with anatak for displaying your overall ranking listing on your rankings page.  Now the code below is what I use for displaying the user's rank on their stats page.  It's the same concept as yours, but I don't have a designated rank field like you.  I just use networth.  It does add a separate call to the db, but it works for me. [code] $query = "SELECT COUNT(*) as rank FROM users         WHERE networth > (SELECT networth FROM users WHERE uid = '$uid')";     $res = mysql_query($query);     $stats['rank'] = mysql_result($res, 0) + 1; [/code] And the credit for that piece of code actually goes to Barand.  I needed that piece of code for something I was working on for my daughter's school, and it also worked out great for my game project.
  3. That did it Barand.  Thanks for everyone's input on this one.
  4. Okay, I'm working on a small project for my daughter's class at school. They have a fundraiser running right now and they want to post their fund raiser data on the their school website. What they want is this, they want a page listing each student and the amount that they've managed to raise so far along with a ranking. Something like this: Teresa H. $85 #1 Jana L. $84 #2 etc...etc... This i've already accomplished. But they also want the ability to list the students alphabetically, which I can do also, but they each name to be clickable with a link to a page about that student containing information about their particular fundraising efforts. I guess a blog of sorts. And I have this written as well. The only thing I can't figure out is how to add each individual ranking to the individual pages. To get the ranking above, I just select all the data from the db and use mysql_numrows($result); with a loop to get the "ranking" but I can't seem to figure this out when I have to use a select statement that requires that the userid be a match. Example: [code] $query = mysql_query("SELECT * FROM students where uid =$uid")   or die(mysql_error());  [/code] Now how do I re-write my select statement to get my overall ranking for each student on their individual page? Here's the basic db structure also: uid, student_name, total_raised, homeroom "total_raised" is the field that I'm using to get my Ranking. Any help would be great b/c I'm stumped on this.
  5. Maybe this line.... [code]$runtrans = mysql_query($banksql) or die("Error<br>".mysql_error());[/code] I could be wrong.
  6. Works perfectly.  Thanks for all your help.  I'll give you my first million $$ when I win the lottery.  :D
  7. Sorry, It left out some info on my post. When I click a link to view my test.php page here is the info returned: [code]http://localhost/project/run.php[/code] And here is the code for my test.php page: [code]$webserver=apache_request_headers(); //if( !eregi($root,$webserver[Referer])) { echo $webserver[Referer];[/code]
  8. Sorry, my bad.  I didn't understand what you were getting at.  I have put a link from a file called run.php to a page that echos $webserver[Referer] and here is what I get when I click the link and view my test.php page: http://localhost/project/run.php
  9. $webserver[Referer] is the apache_request_headers() function.
  10. I'm trying prevent access to pages on my site unless they are called from another page on my server itself and I'm getting the following error: [code]Warning: eregi() [function.eregi]: REG_EMPTY[/code] Here is how I have this set up: [code] //This defines my root folder--In production this will be my domain $root = 'localhost'; //This checks if the page referrer is a local page within my site $webserver=apache_request_headers(); if( !eregi($root,$webserver[Referer])) { //Okay to process here }else{ //Stop Processing } [/code] Can somebody help me out with this?
  11. Not only did that answer this particular question for me, it answered several other questions I had in mind for future issues I foresee with my code.  Thanks.  Your the best.
  12. Okay, I've written a function that returns an array (at least I think I've got the correct format for producing my array.)  This function is called from a separate page within the site.  I need to display my array variables on the page the function is called on to finish processing my script.  Here is what I have so far: [code]function loc_bonus($id) { $loc_high = 5; $loc_med = 3; $loc_low = 1; //Create Array $bonus = array('loc_high'=>$loc_high,'loc_med'=>$loc_med,'loc_low'=>$loc_low) ; return $bonus; }[/code] Now I want to be able to display $loc_low after calling my function on a separate page. Thanks in advance.
  13. Post your actual HTML from your form.  Maybe you have some typos/errors in it also.
  14. I'm most likely going to have to move it to the database.  This would be much simpler, but I'm really just trying to cut down on calls to the database.  Any way, after trying your suggestion, I get the following error: [code]Warning: Cannot use a scalar value as an array in C:\Program Files\xampp\htdocs\thugs\functions.php on line 65 Warning: Cannot use a scalar value as an array in C:\Program Files\xampp\htdocs\thugs\functions.php on line 66[/code] I have no clue what "scalar values" are.  :o
  15. Here's another link for you to look at.  He doesn't provide the source, but he provides an API so you can run the service through own site. [url=http://bluga.net/webthumb/index.php]http://bluga.net/webthumb/index.php[/url]
  16. Oops, forgot something.  The information that I want is in the switch statements basically. For example, If $city = 1 and $location = 1 then result I would be looking for is $echo $loc_pro;  //Should dispay 1.5 $echo $loc_thug;  //Should display 1
  17. Okay, here's what I have going.  I've created a file called cities.php.  This file stores information about cities that I'm using in a site.  Here is what it looks like: [code]if($city == "1"){   $city_name = "New York";   $city_id = "1";   $loc_01 = "Grand Central Station";   $loc_02 = "Central Park";   $loc_03 = "Maxim Lounge";   $loc_04 = "Madison Square Garden";   $loc_05 = "Coney Island";   //Begin City Specific Switch Here //This page New York City locations switch ($location) { case 1:   $location_name = 'Grand Central Station';   $loc_pro = 1.5;   $loc_thug = 1;   break; case 2:   $location_name = 'Central Park';   $loc_pro = 1;   $loc_thug = 1.95;   break; case 3:   $location_name = 'Maxim Lounge';   $loc_pro = 1.25;   $loc_thug = 1;   break; case 4:   $location_name = 'Madison Square Garden';   $loc_pro = 1;   $loc_thug = 1.25;   break; case 5:   $location_name = 'Coney Island';   $loc_pro = 0.5;   $loc_thug = 0.75;   break; } } elseif($city == "2"){ $city_name = "Washington DC";   $city_id = "2";   //Begin City Specific Switch Here }else { echo "You Aren't In Any City"; }[/code] Now what I'm attempting to do is create a function that retrieves the values from the switch statements within cities.php.  So far I have the following function: [code]function city($city,$location)   {   include('cities.php');   return $loc_pro;   return $loc_thug;   }[/code] And my function call is like this: [code]city($city,$location);[/code] So if this is all working correctly I should be able to just pass my variables to my function call and run a simple echo statement to give me the 2 variables in the function that I want.  But obviously this isn't working or I wouldn't be posting it here.  I can get the results I want if I simply edit the cities.php file and include the 2 variables $city and $location and run an echo script at the bottom of the file.  I will show the information that I want.  Whenever I try and do it the way I have it written, I just get a blank screen. Can somebody give me some direction on how to make this work, or is there another option for getting the same results that I want?  Thanks in advance.
  18. I ended up just writing some switch statements and separate files to achieve what I wanted.  As for not wanting it stored in the db, I'm anticipating very high traffic to the db and just want to cut down on unnecessary calls to the db.  I don't mind a separate call to the files in question, I'm just really trying to speed up the database functions.
  19. SELECT * FROM `User` WHERE RankType = 'Active' OR  RankType='Retired'
  20. Okay, here's the problem that I'm having.  I have information stored in a database, but I want to be able to store this information in a file instead of having to call it from the database to save on database traffic.  I think what I need is an array for my data, but I'm not sure.  Here is the database structure: [i]tbl_city[/i] city_id city_name [i]tbl_location[/i] location_id city_id location_name postive_ratings negative_ratings Sample Data would be like this: [i]City[/i]:  New York (city_id#1) [i]Locations[/i]: [b]Central Park[/b] (location_id #1) Positive Ratings: 5 Negative Ratings: 1 [b]Ellis Island[/b] (location_id #2) Positive Ratings: 7 Negative Ratings: 0 The structure of the file I would like to create would be something like this (I think): [b]city id/city name[/b] Location 1 Positve Rating (Location 1) Negative Rating (Location 1) Location 2 Positve Rating (Location 2) Negative Rating (Location 2) etc. Can somebody help me with this.
×
×
  • 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.