Hey Guys,

I found some code from a fellow I used to work with and am trying to dissect what it all means.(b/c im trying to build a similar application). Anyways, I'm pretty much a rookie when it comes to programming; I've really only been doing it for about 3 weeks now. Any help you could provide on what exactly this code means would be appreciated. A walk through would be nice. Here is the part of the code that I dont quite understand:


            $ORIGIN[$Count] = odbc_result($result, "ORIGIN");
            $DESTINATION[$Count] = odbc_result($result, "DESTINATION");
            $rmpPr = $ORIGIN[$Count].$DESTINATION[$Count];          
                $Pairs[] = $Pr;
            $ORIG[$Pr][$END_DATE[$Count]] = odbc_result($result, "ORIG");
            $DEST[$Pr][$END_DATE[$Count]] = odbc_result($result, "DEST");
            $BEGIN_DATE[$Count] = odbc_result($result, "BEGIN_DATE");
            $END_DATE[$Count] = (string)date('m/d/Y',strtotime(trim(odbc_result($result, "END_DATE"))));
            $SS[$Pr][$END_DATE[$Count]] = odbc_result($result, "SS");
            $C1[$Pr][$END_DATE[$Count]] = odbc_result($result, "C1");
            $C2[$Pr][$END_DATE[$Count]] = round(odbc_result($result, "C2"),1);
            $C3[$Pr][$END_DATE[$Count]] = round(odbc_result($result, "C3"),1);
            $C4[$Pr][$END_DATE[$Count]] = round(odbc_result($result, "C4"),1);          
            $C5[$Pr][$END_DATE[$Count]] = round(odbc_result($result, "C5"),1);


foreach($Pairs as $PAID)
                    echo "<tr onMouseover=\"this.bgColor='yellow'\" onMouseout=\"this.bgColor='white'\">";

                        echo "<td>".$ORIG[PAID][$date2]."</td>";
                        echo "<td>".$DEST[PAID][$date2]."</td>";
                        echo "<td Class='p'>".substr($PAID,0,2)."</td>";
                        echo "<td>".substr($PAID,2,2)."</td>";

                            echo "<td Class='p'>".$SS[PAID][$daterange]."</td>";
                            echo "<td>".$C1[PAID][$daterange]."</td>";
                            echo "<td>".$C2[PAID][$daterange]."</td>";
                            echo "<td>".$C3[PAID][$daterange]."</td>";
                            echo "<td>".$C4[PAID][$daterange]."</td>";                                    
                            echo "<td Class='c'>".$C5[$PAID][$daterange]."</td>";


The beginning of the code (while statement) start from pulling information for a database. $daterange is an inputed date. One thing that threw me for a loop is $date2. It seems like it is nothing more than a place holder. I've looked through the entire code and is not referenced anywhere else. So it's like it was just stuck in there, but when I take $date2 out it doesn't work and when I output it, its blank.

To make matters short, the part I dont understand is how the double arrays work. The main function of this code was to match up pairs from different date periods. For example if you had pair New York - San Diego, you would have all the information on one line for both dates instead of having a seperate line for each date. But exactly how that works in this code I cannont quite grasp.

Thus said, being a rookie to this sort of thing, I probably left important information out, if so just let me know.

Thanks for the help and clarrification.

Member Avatar


Thus said, being a rookie to this sort of thing, I probably left important information out, if so just let me know.

I'm not sure you figure out this already. If this your first time learning how ODBC function works. Then you might have to take time to learn it. Think it as learning OOP functions.

Here is a link about how ODBC works:


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.