i need help to show data from mySQL db i certain way. I have 2 tables in DB, one that has program for the day (channelID, name, time) and one that has references to time blocks with links to load appropriate video (id, channelID, url). the program can have multiple entries per hour (f.e. 10:00 news, 11:30 weather) but the links are fixed in 1 hr intervals. i need to show the program in 2 columns:
10:00 news
11:30 weather
and load appropriate link so if the interval is between 10:00:00-10:59:59 load url for 10hr block (so the news would be clickable and would link to 10hr.m3u8 f.e.), if 11:00:00-11:59:59 load the 11hr block (so the weather would be clickable and would link to 11hr.m3u8 f.e.)
I don’t see DATE field anywhere and it’s a little unclear of table names. Actual display of programs by time could be done after data for the day has been grabbed… Here’s a wild stab at a query.
$sql = "SELECT
p.channelID
, p.name
, p.time
, t.url
FROM programs as p
LEFT JOIN time_blocks as t
ON t.channelID = p.channelID
ORDER BY p.time ASC";
the DATE field is column “start” in “epg table” the times do not align with the time blocks… in the programs, i can have f.e. 10:00 am - Program 1, 10:15 am - Program 2, 10:45am - program 3 , but in the other table time blocks that span 1 hour at a time. so each channel would have 24 url. here is the structure exactly:
i was thinking i could have 2 separate queries; 1 to retrieve the data from epg table and one from tblMobile, store the tblMobile in an array and then search the array at every time the loop happens for the epg data writing to the page and pull appropriate link. but i was unsuccessful with that.
Is it possible to POST sql you are working with and what you’ve tried?
It is still unclear the relationship… as you use different terms when talking about what you’s like than the actual table names. I am thinking now that your tblMobile table is your primary table with time blocks stored in the field timeBlockIndicator but what kind of data is it holding? Just the hour? 10:00:00 or some other value.
epg then has specific programs (shows, videos whatever) 10:00 am - Program 1, 10:15 am - Program 2, 10:45am - program 3
the timeBlockIndicator field has just values 0,1,2,3… 24 so it indicates what time block that url is for f.e. 01:00am - 01:59am, the timeBlockIndicator value is1
the epg table holds values for program data (here is a sample of a row):
id_epg id_channel start title description
124227009 40 2015-08-23 23:55:00 Ma reggel Felirato… oldalán!
unfortunately i don’t think it worked. here is the data and the column names to maybe demonstrate better what i need. I can change anything in the tblMobile if needed but can’t do any modifications on the epg table as that is a 3rd party data that is dumped into our DB daily.
id_epg id_channel start title
124719306 2 2015-08-27 00:05:00 BET LECHEM - vnitřní domov
124719308 2 2015-08-27 00:20:00 Putování modrou planetou
124719310 2 2015-08-27 01:00:00 Zambijský Bambomisioná…
124719312 2 2015-08-27 01:25:00 Cesta do turecké země
124719314 2 2015-08-27 01:45:00 Volání Etiopie. Situace katolické církve v Etiopii
124719316 2 2015-08-27 02:00:00 Se salesiány na jihu Madagaskaru
124719318 2 2015-08-27 02:20:00 Na jedné lodi
124719320 2 2015-08-27 03:25:00 Poutní chrám Panny Marie na Chlumku v Luži
124719322 2 2015-08-27 03:35:00 Přejeme si
124719324 2 2015-08-27 03:50:00 Dát smysl života
Ok, so from this example all titles from epg table f.e. between 01:00:00through 01:59:59 would be linked using link ending in 01.m3u8 with mobileIndicator 1s. then each record between 02:00:00 through 02:59:59 would be linked with link ending in 02.m3u8 with mobileIndicator 2s. hope this makes more sense.
I thought you said mobileIndicator would have hour numbers (0-24) but looking at your post they have an ‘s’ after the number. If you add the ‘s’ after the number on these lines does it show records?
if (array_key_exists($h.'s',$data)){
foreach($data[$h.'s'] as $showtime => $showdata):
I get nothing, blank page. it is like it doesn’t move pass the connection to the DB. i don’t get an error msg that it didn’t connect to the DB. i just get blank page. I tried to put simple echo(“test”); after the connection and did not even get that. I included the user name, password and name of the DB into the variables. this may be possibly due to PHP 5.0.4 version we are using?
Are you saying you don’t see the echo "Connected successfully"; line?
If you are not getting an error on connection, what does the rest of your code specifically the query look like? Have you compared table and field names to make sure they are correct? If you don’t spot a problem, wrap the query in the same kind of TRY/CATCH block to show errors
i don’t get echo for either Connected successfully nor Error. i will double check the query one more time. at the moment i get white page, nothing on it