PHP/MYSQL dynamic query

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Todlerone
Forum Commoner
Posts: 96
Joined: Sun Oct 28, 2007 10:20 pm
Location: Hamilton, Ontario, Canada

PHP/MYSQL dynamic query

Post by Todlerone »

Hello all. TY in advance for any help/suggestions. I'm trying to do a dynamic php mysql search. This doesn't seem to work, so I was wondering where I went wrong.

Code: Select all

$query = "SELECT game_date, game_park, game_vis, game_home, game_vis1, game_home1, game_vis2, game_home2, game_status1, game_status2 FROM schedule09 RIGHT JOIN scores09 ON schedule09.game_id= scores09.game_id WHERE game_week = $week order by schedule09.game_date";
The $week variable is calculated to select a certain week only (eg: 1 or 2, etc). There is a column in the db for game_week.

What I'm trying to do is select from two different tables.

1) From schedule09 I need game_(date, park, vis, home, week)
2) From scores09 I need game_(vis1, home1, vis2, home2, status1, status2).
They are foreign linked by a game_id column.

TY
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: PHP/MYSQL dynamic query

Post by Darhazer »

Post the next few statements.
output the contents of the query variable
If the result from the query is false, post the output of mysql_error() as well
Post Reply