i'm seeking help for a page that supposed to return db results on a query about bus-route times-- part of what's going to be a "Journey / Trip Planner" for a small-city public transport bus co. this particular piece is the first that any of my "back-end" and my ("finished") database will finally function to produce a result of tangible, useful data. i have spent all of the time thus far (since early Dec) testing small bits of code, creating input forms to transfer Excel data into the db, etc-- all toward getting the MySQL db where i need it to be for a successful app to function.
i've finally reached the point of "readiness" for trying to crunch my data, and finally begin developing the actual front-end-- albeit, still very much just trying stuff to see what happens.
i posted 2 informative pages showing my db tables. please observe them, and then read on.
shown in my illustration at the link, you see that i am working w/ two particular bus-routes, which service two different areas of town, but a bus patron might ride busA to busB and continue his or her trip. i need to make use of that data shown in the illustration to produce estimations about when the bus patron might want to stand at his neighborhood/ street's bus-stop, and also to inform that potential patron when he or she might arrive at her destination.
EDIT: and to also allow for a third stop being a "changeover" from busA to busB, a most critical aspect of the app
EDIT2: for the record-- it's the manipulation of a particular bit of data that i sought here-- but this thread went off on a particular issue related to what mr thorpe sees as a critical flaw in my db design. i'm still interested in the original inquiry i've posted here.
below is my first attempt at crunching this data. this is supposed to show me all of the available times for a single bus-stop (eg. bus-patron "Joe" seeking info about his nearest bus-stop, identifed by code "wc13e" [each represents a unique geographical location] ). my thoughts are that i need to know every possible time of day the bus will pass "Joe's" stop, so he knows his options.
My problem w/ the code is that it doesn't report AM and PM correctly, although it is showing the proper times as queried from the fields "rt01 - rt22" as shown in Fig 2.1.
here's what i have:
$htmlblock = "<p>The route times for bus stop $stop_code are:</p>
<ul style=\"list-style-type:none;\">";
for($x=1;$x<=22;$x++) {
$pad = str_pad($x, 2, "0", STR_PAD_LEFT);
$fieldname=${"rt".$pad};
$blue = " style=\"color:blue;\">";
$red = " style=\"color:red;\">";
$time = strtotime($fieldname);
if(($x >6) && ($fieldname >= '12:39:00')) {
$fieldname = $fieldname." pm";
$fieldname = "$blue".$fieldname;
} else {
$fieldname = $fieldname." am";
$fieldname = "$red".$fieldname;
}
/* if( ($x <= 6) && ($fieldname < '12:39:00') ) {
$fieldname = $fieldname." am";
} elseif( ($x >= 6) && ($fieldname >= '12:39:00') ) {
*/
$htmlblock .= "<li".$fieldname."</li>";
}
$htmlblock .="</ul>";
one concern that i have is my logic if(($x >6), which bases the AM / PM not on time value, but on my knowledge of which trip revolution the bus is on throughout the day-- this of course is unreliable, as some buses will make more or less revolutions (routes, trips... whatever you want to call how many times they run per day), which are represented by the fields referenced above in fig 2.1
that's all i have for now. thank you so much for reading. i am very eager to read any replies. thanks again!!!
by the way-- if you recognize if i'm headed for potential disaster, etc., please advise however you'd like.
(please consider also that i'm relatively new to programming-- not using as an excuse, but just keep in mind i haven't much experience so i often overlook the obvious, or simply am unaware of obvious solutions.)