Page 1 of 1
table include
Posted: Tue Jun 23, 2009 3:52 am
by WayneG
Hi.
I want to use this text in an include file: "demo_2".
demo_2 is a table name in a database.
I want to call this table from a select statement from another file, i.e
Code: Select all
$result = mysql_query('SELECT * FROM include("../inc.LeagueNameLower1.php"); WHERE Match_No=1')
This obviously doesn't work, but is there a way of doing it?
Cheers.
Re: table include
Posted: Tue Jun 23, 2009 4:00 am
by waseem83
I hope there will be a solution for this. But i dont know any.
Re: table include
Posted: Tue Jun 23, 2009 4:01 am
by onion2k
Code: Select all
$table = file_get_contents("../inc.LeagueNameLower1.php");
$result = mysql_query("SELECT * FROM $table WHERE Match_No=1");
But.. why?! I can't think of a single reason why you'd want to do that.
Re: table include
Posted: Tue Jun 23, 2009 6:49 am
by WayneG
Thanks.
Does it really matter why?
Re: table include
Posted: Tue Jun 23, 2009 6:59 am
by Eric!
This is how an include works. Your inc.LeagueNameLower1.php file
Your main script
Code: Select all
include "../inc.LeagueNameLower1.php";
$result = mysql_query("SELECT * FROM $table WHERE Match_No=1");
I have no idea why in the world you would do this for a table.
EDIT why are my tags not working?
Re: table include
Posted: Tue Jun 23, 2009 7:54 am
by onion2k
WayneG wrote:Does it really matter why?
Not really. It's just that you appear to be writing some
really bad code. If you can explain why you're doing it we might well be able to offer some advice about how you can improve it.
Re: table include
Posted: Tue Jun 23, 2009 8:56 am
by WayneG
Oh. Ok.
I am a novice at this, so I'm pretty sure its bad code!
The thing is, I try to keep it simple in such a way I can understand what I'm doing.
I'll try to explain:
I have a template directory which I use to copy to create other directories, each will have their own name/DB name etc. I have 132 folders (named 1-132), with identical files in. In 2 of the files I have a select statement. Instead of having to change the "select demo_1 ..." table in each file, I was thinking of having this statement in a separate file, so I would only have to change this file instead of everything in the 132 folders.
I realise this is still bad coding. Hope you can understand the waffle.
Wayne.