TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,004
  • Total Topics: 21,330
  • Online today: 219
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 142
  • Total: 143
  • tino

I'm stoooopid.

Started by TWD, April 03, 2007, 05:05:08 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

TWD

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.

TWD

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?

JPDeni

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;

This website is proudly hosted on Crocweb Cloud Website Hosting.