Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
PHP
$dep_re = $_POST['dpt_from'];
    $arive_re = $_POST['arive_to'];
    $day_re = $_POST['day_re'];
    $month_re = $_POST['month_re'];
    $year_re = $_POST['year_re'];
    $time_re = $_POST['time_re'];
    $adult_re = $_POST['no_of_pax_adult'];
    $child_re = $_POST['no_of_pax_child'];
   $date_re = "$year_re-$month_re-$day_re";

    $connectSQL = mysql_connect("localhost","root","");
     if (!$connectSQL)
        die("Database Not Found".mysql_error());

    $connectSelectdb = mysql_select_db("bobdatabse");
    if (!$connectSelectdb)
        die("Error connect to database".mysql_error());

    else{

        $query = "SELECT * FROM trip_info WHERE date='$date' AND time='$time' AND depart='$dep' AND arive='$arive'";
        //$query_re = "SELECT * FROM round_trip_info WHERE date_re='$date_re' AND time_re='$time_re' AND depart_re='$dep_re' AND arive_re='$arive_re'";
        $result = mysql_query($query);
        //$result_re = mysql_query($query_re);

        if(!$result)
            die("invalid query!".mysql_error());
        else
            echo "<form name=listtrip method=post action=Reservation.php>";
            echo "<b>$dep</b> to <b>$arive</b>";
            echo "<table border=1px>";
            echo "<tr><td>Date</td><td>Time</td><td>Departure</td><td>Arive</td><td>Price Adult</td><td>Price Child</td><td></td></tr>";
            while($row=mysql_fetch_array($result))
            {
                echo "<tr><td>".$row['date']."</td><td>".$row['time']."</td><td>".$row['depart']."</td><td>".$row['arive']."</td><td>".$row['adult']." x ".$adult."=".$row['adult'] * $adult."</td><td>".$row['child']." x ".$child."=".$row['child'] * $child."</td><td><input type=submit value=Booking Now></td></tr>";
            }
            echo "</table><br>";




            $connectSQL = mysql_connect("localhost","root","");
            if (!$connectSQL)
                die("Database Not Found".mysql_error());

            $connectSelectdb = mysql_select_db("bobdatabse");
                if (!$connectSelectdb)
                    die("Error connect to database".mysql_error());

            else{

            $query_re = "SELECT * FROM round_trip_info WHERE date_re='$date_re' AND time_re='$time_re' AND depart_re='$dep_re' AND arive_re='$arive_re'";
            $result_re = mysql_query($query_re);

            if(!$query_re)
                die("invalid query!".mysql_error());
            echo "<form name=listtrip method=post action=Reservation.php>";
            echo "<b>$arive</b> to <b>$dep</b>";
            echo "<table border=1px>";
            echo "<tr><td>Date</td><td>Time</td><td>Departure</td><td>Arive</td><td>Price Adult</td><td>Price Child</td><td></td></tr>";
            while($row_re = mysql_fetch_array($result_re,MYSQL_BOTH))
            {
                echo "<tr><td>".$row_re['date_re']."</td><td>".$row_re['time_re']."</td><td>".$row_re['depart_re']."</td><td>".$row_re['arive_re']."</td><td>".$row_re['adult_re']." x ".$adult_re."=".$row_re['adult_re'] * $adult_re."</td><td>".$row_re['child_re']." x ".$child_re."=".$row_re['child_re'] * $child_re."</td><td><input type=submit value=Booking Now></td></tr>";
            }
            echo "</table>";





}
}
Posted
Comments
thatraja 2-Sep-14 3:36am    
what's the error?
JaironLanda 2-Sep-14 6:11am    
the error is this loop

while($row_re = mysql_fetch_array($result_re,MYSQL_BOTH))
{
echo "<tr><td>".$row_re['date_re']."</td><td>".$row_re['time_re']."</td><td>".$row_re['depart_re']."</td><td>".$row_re['arive_re']."</td><td>".$row_re['adult_re']." x ".$adult_re."=".$row_re['adult_re'] * $adult_re."</td><td>".$row_re['child_re']." x ".$child_re."=".$row_re['child_re'] * $child_re."</td><td><input type=submit value=Booking Now></td></tr>";
}

im tired changing the loop but doesn't show any error..and this loop not showing my table..
JaironLanda 2-Sep-14 6:13am    
the 1st table is working properly

1 solution

The problem is with the echo line

PHP
echo "<table><tbody><tr><td>".$row_re['date_re']."</td><td>".$row_re['time_re']."</td><td>".$row_re['depart_re']."</td><td>".$row_re['arive_re']."</td><td>".$row_re['adult_re']." x ".$adult_re."=".$row_re['adult_re'] * $adult_re."</td><td>".$row_re['child_re']." x ".$child_re."=".$row_re['child_re'] * $child_re."</td><td><input type=submit value=Booking Now></td></tr></tbody></table>";


HTML will be generated like
HTML
<input type="submit" value="Booking" now="" /> 


so there shouldnt be any space. If you want to leave a space enclose the values in a single quotes like

HTML
<input type="submit" value="Booking now" />
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900