1. PHP / Говнокод #4435

    +161

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    function getItinerary($IID){
        $connection = initDB();
        $query;
    
        if($IID == 0){
                $query = "SELECT * FROM Itinerary";                
            }
            else{
                $query = "SELECT * FROM Itinerary WHERE IID='".$IID."'";               
            }
    
    
        $result = mysql_query($query);
            //or die ("Query Failed ".mysql_error());
    
        $itineraryID = 0;
        $itineraryData;
    
        while($row = mysql_fetch_array($result)){   
                $GID = $row['GID'];
                $FID = $row['FID'];
                $SID = $row['SID'];
                    
                    //Retrieve Guest Information
                $query2 = "SELECT * FROM Guest WHERE GID='".$GID."'";
                $result2 = mysql_query($query2);
                $row2 = mysql_fetch_array($result2);
                $firstName = $row2['FirstName'];
                $lastName = $row2['LastName'];
                    
                    //Retrieve Travel Schedule Information
                $query3 = "SELECT * FROM Schedule WHERE SID='".$SID."'";
                $result3 = mysql_query($query3);
                $row3 = mysql_fetch_array($result3);
                $travelDate = $row3['Date'];
                    
                    //Retrieve Sector Information
                $query3 = "SELECT * FROM Flights WHERE FID='".$FID."'";
                $result3 = mysql_query($query3);
                $row3 = mysql_fetch_array($result3);
                $sourceSID = $row3['SourceSID'];
                $destSID = $row3['DestSID'];
                $fName = $row3['FName'];
            
                $query4 = "SELECT Sector FROM Sectors WHERE SID='".$sourceSID."'";
                $result4 = mysql_query($query4);
                $row4 = mysql_fetch_array($result4);
                $source = $row4['Sector'];
                $query4 = "SELECT Sector FROM Sectors WHERE SID='".$destSID."'";
                $result4 = mysql_query($query4);
                $row4 = mysql_fetch_array($result4);
                $dest = $row4['Sector'];
                    
                    //Build GuestItinerary object   
                $guestItinerary = new GuestItinerary();
            
                $guestItinerary->set_FID($FID);
                $guestItinerary->set_FName($fName);
                $guestItinerary->set_SID($SID);
                $guestItinerary->set_source($source);
                $guestItinerary->set_dest($dest);
                $guestItinerary->set_travelDate($travelDate);
            
                $guestItinerary->set_GID($GID);
                $guestItinerary->set_firstName($firstName);
                $guestItinerary->set_lastName($lastName);    
            
                $itineraryData[$itineraryID]=$guestItinerary;
                $itineraryID = $itineraryID + 1; 
            
            }
    
        closeDB($connection);      
        return $itineraryData;
    }

    Из демонстрационного приложения к NetBeans. Для обучения новичков, ага.

    Запостил: seonull, 25 Октября 2010

    Комментарии (4) RSS

    Добавить комментарий