1

我正在开发 Flight 门户。让我们假设有两个页面(Search.php、Result.php)。

在搜索页面中,我们将选择来源、目的地、旅程日期等(现在我们将点击搜索按钮)

单击搜索按钮后,页面将重定向到 Result.php,我们将在那里显示结果。

在页面上显示结果之前,我试图将这些结果插入到数据库中,如下所示。

$q=0;
    foreach($array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'] as $main)
    {
        $f1=$basefare[$q]=$array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'][$q]['FareDetails']['ActualBaseFare'];

        $f10=$octax[$q]=$array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'][$q]['FareDetails']['ocTax'];

        $f11=$pcom[$q]=$array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'][$q]['FareDetails']['TPartnerCommission'];

        $f12=$tsdiscount[$q]=$array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'][$q]['FareDetails']['TSdiscount'];

        $f2=$tax[$q]=$array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'][$q]['FareDetails']['Tax'];

        $f3=$stax[$q]=$array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'][$q]['FareDetails']['STax'];

        $f4=$tcharge[$q]=$array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'][$q]['FareDetails']['TCharge'];

        $f5=$scharge[$q]=$array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'][$q]['FareDetails']['SCharge'];

        $f6=$tdiscount[$q]=$array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'][$q]['FareDetails']['TDiscount'];

        $f7=$tmarkup[$q]=$array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'][$q]['FareDetails']['TMarkup'];

        $f8=$fid[$q]=$array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'][$q]['id'];

        $f9=$fkey[$q]=$array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'][$q]['key'];

        $ft=$totalfare[$q]=($basefare[$q]+$tax[$q]+$stax[$q]+$scharge[$q])-$tdiscount[$q];

        $a1=$abasefare[$q]=$array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'][$q]['FareDetails']['FareBreakup']['FareAry']['Fare']['BaseFare'];

        $a2=$atax[$q]=$array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'][$q]['FareDetails']['FareBreakup']['FareAry']['Fare']['Tax'];

        if($child>0 || $infant>0)
        {
        $a1=$abasefare[$q]=$array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'][$q]['FareDetails']['FareBreakup']['FareAry']['Fare'][0]['BaseFare'];

        $a2=$atax[$q]=$array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'][$q]['FareDetails']['FareBreakup']['FareAry']['Fare'][0]['Tax'];
        }

        if($child>0)
        {
        $c1=$cbasefare[$q]=$array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'][$q]['FareDetails']['FareBreakup']['FareAry']['Fare'][1]['BaseFare'];

        $c2=$ctax[$q]=$array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'][$q]['FareDetails']['FareBreakup']['FareAry']['Fare'][1]['Tax'];
        }

        if($child>0)
        {
        $i1=$ibasefare[$q]=$array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'][$q]['FareDetails']['FareBreakup']['FareAry']['Fare'][2]['BaseFare'];

        $i2=$itax[$q]=$array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'][$q]['FareDetails']['FareBreakup']['FareAry']['Fare'][2]['Tax'];
        }

        if($child==0)
        {
        $i1=$ibasefare[$q]=$array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'][$q]['FareDetails']['FareBreakup']['FareAry']['Fare'][1]['BaseFare'];

        $i2=$itax[$q]=$array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'][$q]['FareDetails']['FareBreakup']['FareAry']['Fare'][1]['Tax'];
        }

    $s=0;
    foreach($array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'][$q]['onward']['FlightSegments']['FlightSegment'] as $array)
    {
            $z1=$flightnumber[$q][$s]=$array['FlightNumber'];
            $z2=$airlinename[$q][$s]=$array['OperatingAirlineName'];
            $z3=$airlineflightnumber[$q][$s]=$array['OperatingAirlineFlightNumber'];
            $z4=$airlinecode[$q][$s]=$array['OperatingAirlineCode'];
            $z5=$departureloc[$q][$s]=$array['DepartureAirportName'];
            $z6=$departurecode[$q][$s]=$array['DepartureAirportCode'];
            $z7=$arrivalloc[$q][$s]=$array['ArrivalAirportName'];
            $z8=$arrivalcode[$q][$s]=$array['ArrivalAirportCode'];
            $z9=$departuretime[$q][$s]=$array['DepartureDateTime'];
            $z10=$arrivaltime[$q][$s]=$array['ArrivalDateTime'];
            $z11=$airequiptype[$q][$s]=$array['AirEquipType'];
            $z12=$linksell[$q][$s]=$array['LinkSellAgrmnt'];
            $z13=$conx[$q][$s]=$array['Conx'];
            $z14=$airpchg[$q][$s]=$array['AirpChg'];
            $z15=$insideavailoption[$q][$s]=$array['InsideAvailOption'];
            $z16=$gentrafrestriction[$q][$s]=$array['GenTrafRestriction'];
            $z17=$DaysOperates[$q][$s]=$array['DaysOperates'];

            $z30=$enddate[$q][$s]=$array['EndDt'];      
            $z31=$oaf[$q][$s]=$array['OperatingAirlineFlightNumber'];       
            $z32=$nstops[$q][$s]=$array['NumStops'];        
            $z18=$JrnyTm[$q][$s]=$array['JrnyTm'];      
            $z19=$StartTerminal[$q][$s]=$array['StartTerminal'];        
            $z20=$EndTerminal[$q][$s]=$array['EndTerminal'];        
            $z21=$FltTm[$q][$s]=$array['FltTm'];        
            $z22=$LSAInd[$q][$s]=$array['LSAInd'];      
            $z23=$Mile[$q][$s]=$array['Mile'];

            $z24=$avail[$q][$s]=$array['BookingClass']['Availability'];     
            $z29=$bic[$q][$s]=$array['BookingClass']['BIC'];        
            $z25=$bookingclass[$q][$s]=$array['BookingClassFare']['bookingclass'];      
            $z26=$classtype[$q][$s]=$array['BookingClassFare']['classType'];        
            $z27=$farecode[$q][$s]=$array['BookingClassFare']['farebasiscode'];
            $z28=$rule[$q][$s]=mysql_real_escape_string($array['BookingClassFare']['Rule']);





                $mysql_query="insert into RviewInternationalFlight (q,s,FlightNumber,OperatingAirlineName,OperatingAirlineFlightNumber,OperatingAirlineCode,DepartureAirportName,DepartureAirportCode,ArrivalAirportName,ArrivalAirportCode,DepartureDateTime,ArrivalDateTime,ip,airequiptype,linksell,conx,airpchg,insideavailoption,gentrafrestriction,DaysOperates,JrnyTm,StartTerminal,EndTerminal,FltTm,LSAInd,Mile,availability,bookingclass,classtype,farecode,rule,basefare,tax,stax,tcharge,scharge,tdiscount,tmarkup,fid,fkey,totalfare,adultfare,adulttax,childfare,childtax,infantfare,infanttax,BIC,enddate,oaf,octax,numstops,tpc,tsdiscount) values('$q','$s','$z1','$z2','$z3','$z4','$z5','$z6','$z7','$z8','$z9','$z10','$ip','$z11','$z12','$z13','$z14','$z15','$z16','$z17','$z18','$z19','$z20','$z21','$z22','$z23','$z24','$z25','$z26','$z27','$z28','$f1','$f2','$f3','$f4','$f5','$f6','$f7','$f8','$f9','$ft','$a1','$a2','$c1','$c2','$i1','$i2','$z29','$z30','$z31','$f10','$z32','$f11','$f12')";

                mysql_query($mysql_query) or die(mysql_error());


    $s++;
    }
    $count[$q]=$s-1;


    $r=0;
    foreach($array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'][$q]['Return']['FlightSegments']['FlightSegment'] as $array)
    {
            $z1=$rflightnumber[$q][$r]=$array['FlightNumber'];
            $z2=$rairlinename[$q][$r]=$array['OperatingAirlineName'];
            $z3=$rairlineflightnumber[$q][$r]=$array['OperatingAirlineFlightNumber'];
            $z4=$rairlinecode[$q][$r]=$array['OperatingAirlineCode'];
            $z5=$rdepartureloc[$q][$r]=$array['DepartureAirportName'];
            $z6=$rdeparturecode[$q][$r]=$array['DepartureAirportCode'];
            $z7=$rarrivalloc[$q][$r]=$array['ArrivalAirportName'];
            $z8=$rarrivalcode[$q][$r]=$array['ArrivalAirportCode'];
            $z9=$rdeparturetime[$q][$r]=$array['DepartureDateTime'];
            $z10=$rarrivaltime[$q][$r]=$array['ArrivalDateTime'];
            $z11=$rairequiptype[$q][$r]=$array['AirEquipType'];
            $z12=$rlinksell[$q][$r]=$array['LinkSellAgrmnt'];
            $z13=$rconx[$q][$r]=$array['Conx'];
            $z14=$rairpchg[$q][$r]=$array['AirpChg'];
            $z15=$rinsideavailoption[$q][$r]=$array['InsideAvailOption'];
            $z16=$rgentrafrestriction[$q][$r]=$array['GenTrafRestriction'];
            $z17=$rDaysOperates[$q][$r]=$array['DaysOperates'];

            $z30=$renddate[$q][$r]=$array['EndDt'];     
            $z31=$roaf[$q][$r]=$array['OperatingAirlineFlightNumber'];      
            $z32=$rnstops[$q][$r]=$array['NumStops'];       
            $z18=$rJrnyTm[$q][$r]=$array['JrnyTm'];     
            $z19=$rrtartTerminal[$q][$r]=$array['StartTerminal'];       
            $z20=$rEndTerminal[$q][$r]=$array['EndTerminal'];       
            $z21=$rFltTm[$q][$r]=$array['FltTm'];       
            $z22=$rLSAInd[$q][$r]=$array['LSAInd'];     
            $z23=$rMile[$q][$r]=$array['Mile'];

            $z24=$ravail[$q][$r]=$array['BookingClass']['Availability'];        
            $z29=$rbic[$q][$r]=$array['BookingClass']['BIC'];       
            $z25=$rbookingclass[$q][$r]=$array['BookingClassFare']['bookingclass'];     
            $z26=$rclasstype[$q][$r]=$array['BookingClassFare']['classType'];       
            $z27=$rfarecode[$q][$r]=$array['BookingClassFare']['farebasiscode'];
            $z28=$rrule[$q][$r]=mysql_real_escape_string($array['BookingClassFare']['Rule']);



                $mysql_query="insert into RviewInternationalFlight (q,r,FlightNumber,OperatingAirlineName,OperatingAirlineFlightNumber,OperatingAirlineCode,DepartureAirportName,DepartureAirportCode,ArrivalAirportName,ArrivalAirportCode,DepartureDateTime,ArrivalDateTime,ip,airequiptype,linksell,conx,airpchg,insideavailoption,gentrafrestriction,DaysOperates,JrnyTm,StartTerminal,EndTerminal,FltTm,LSAInd,Mile,availability,bookingclass,classtype,farecode,rule,basefare,tax,stax,tcharge,scharge,tdiscount,tmarkup,fid,fkey,totalfare,adultfare,adulttax,childfare,childtax,infantfare,infanttax,BIC,enddate,oaf,octax,numstops,tpc,tsdiscount) values('$q','$r','$z1','$z2','$z3','$z4','$z5','$z6','$z7','$z8','$z9','$z10','$ip','$z11','$z12','$z13','$z14','$z15','$z16','$z17','$z18','$z19','$z20','$z21','$z22','$z23','$z24','$z25','$z26','$z27','$z28','$f1','$f2','$f3','$f4','$f5','$f6','$f7','$f8','$f9','$ft','$a1','$a2','$c1','$c2','$i1','$i2','$z29','$z30','$z31','$f10','$z32','$f11','$f12')";

                mysql_query($mysql_query) or die(mysql_error());


    $r++;
    }
    $rcount[$q]=$r-1;

    $q++;
    }

结果被插入到数据库中。到这里为止没问题。但是在将结果插入数据库后,页面停止在那里并显示一个空白页面。

为什么会这样。因为多个循环..?? 可能是什么问题..?

有什么建议么..

谢谢。

4

0 回答 0