TinyPortal

General => Chit chat => Topic started by: TWD on April 03, 2007, 05:05:08 PM

Title: I'm stoooopid.
Post by: TWD on April 03, 2007, 05:05:08 PM
I had no idea where to put this, so forgive me if "Chit chat" is the wrong forum.  As far as that goes, forgive me if this is the wrong website; but I know that there are lots of smart people here who can read my question and laugh and laugh...and hopefully answer it for me.

Very simply, I don't know squat about PHP; but I've managed to write a few of my own pages (I run a football team's site) and I'm trying to get one to accept different criteria for a (very simple) query.  Doing this will allow me to create a number of other pages with the same basic idea.

The query that currently WORKS is as follows:

$query = db_query("SELECT * FROM smf_uffp_schedules WHERE scheduleyear = 2007", __FILE__, __LINE__);

I want to be able to pass the year to the query using a variable.  To that end, I've created a thing called $currentyear in my settings.php file and I've tried various ways to use $currentyear instead of 2007 in the above query.  In each case, I've gotten errors back.

This is important for me because once I make it work, I'll be able to create dynamic variables ($lastyear, $nextyear) and allow the user to move easily between each yearly schedule in the database (there are about 25 years' worth of schedules in my database).  This will also work for things like Rosters, Conference Standings, Players of the Game, etc.  But I can't do it until I figure out how to concatenate the variable "$currentyear" into the query.

In the words of the fly, "Heeeeelp Meeeeee!"    :uglystupid2:

Thanks much.
Title: Re: I'm stoooopid.
Post by: TWD on April 03, 2007, 05:08:52 PM
Okay, I'm even stupider.

I can make the query work, but only if I declare "$currentyear = 2007" in the same function.  How do I set a global variable?
Title: Re: I'm stoooopid.
Post by: JPDeni on April 03, 2007, 06:16:44 PM
QuoteHow do I set a global variable?

In both the script that calls the function and in the function itself, include, as the first line:


global $currentyear;