Jump to content

php mysql question


erdomester

Recommended Posts

Hi!

I have a program working this way (simplified version):

1. User selects something from a dropdownbox which is filled up with records of specified MySQL tables.

2. Program checks which tables comprises this something.

3. If a table comprises it, it selects another table with a similar name and do things with it.

 

e.g.

There are bus timetables as

206, 260, 150 etc. with a coloumn containg all the bus stops.

206_times, 260_times, 150_times containing the timetables.

 

1.User selects bus stop "something street"

2.Program checks through 206,260,150 etc. tables.

3. 206 and 150 comprises "something street" so it opens 206_times and 150_times and read times out like

 

4 | 50

5 | 20 50

6 | 00 15 30 45

(leaving time from the terminus)

 

But what if there are different timetables for M-T, F or the weekend, summer time etc

If today is "W" program should check all tables like 206_times_MTWT, 206_times_F, 206_times_Summer to find out which comprises letter "W". Then if there is a match there comes point 3. (And of course I should create these databases which is inevitable.)

 

I start with

 

if ($selected == $row_t['STOPS']) // which is in a while loop and examines all tables containing the selected bus stop.
//Then in this there is a
$query = "SELECT * FROM $array[$i]"."_times";    //  e.g. 206_times if table "206" contains the selected bus stop.
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
while ($row_p= mysql_fetch_array($result))  
{...}

I thought to run a for loop after putting all corresponding tables in an array like if today is Wednesday, checking all tables containing "W" and putting them into an array.

But how can I examine if a tablename contains a letter or a string?

 

Maybe I should do something with the row

$query = "SELECT * FROM $array[$i]"."_times"; like WHERE...

 

Any ideas? Is that a good method?

Link to comment
https://forums.phpfreaks.com/topic/158600-php-mysql-question/
Share on other sites

Maybe my query line shoud look like

$query = "SELECT * FROM $newarray[$i];

 

And before this I should make a query that (e.g. if bus "206" comprises "something street") checks all tables whose names contain "206_times" and "W" (if today is Wednesday).

So I may need something like SHOW TABLES FROM DATABASE_NAME WHERE table_name contains 206_times and W....

 

What do U think?

Link to comment
https://forums.phpfreaks.com/topic/158600-php-mysql-question/#findComment-836478
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.