Question

Here is my code of program:

<?php



error_reporting(E_ALL);
ini_set('display_errors', true);

$host           = "localhost";
$user_name      = "usr";
$pwd            = "pwd";
$database_name  = "my2"; //assuming you created this

mysql_connect($host, $user_name, $pwd)or die(mysql_error());
mysql_select_db($database_name)or die(mysql_error());

$datee              = $_POST['datee'];
$time               = $_POST['time'];
$destination        = $_POST['destination'];
$days               = $_POST['days'];
$cab                = $_POST['cab'];
$route              = $_POST['route'];
$full_name          = $_POST['full_name'];
$address            = $_POST['address'];
$mobile_number      = $_POST['mobile_number'];
$pickup_location    = $_POST['pickup_location'];

$query2 = "SELECT `order_number` FROM `count` WHERE 1";
$countQuery = mysql_query($query2)or die(mysql_error());

while($row = mysql_fetch_array($countQuery))
{
    $order_number = $row["order_number"];
}

$query3 = "UPDATE `count` SET `order_number` = '".$order_number."'+ 1 WHERE 1";
mysql_query($query3)or die(mysql_error());

$query1="INSERT INTO booking VALUES     ('".$datee."','".$time."','".$destination."','".$days."','".$cab."','".$full_name."','".$ad       dress."','".$mobile_number."','".$pickup_location."','".$route."','".$order_number."')";
mysql_query($query1)or die(mysql_error());
?>

<html>
<body>
<div style="border:1px solid black;background-color:#FAFA23;width:600px;height:100px;">
<table>
<tr>
<td>
<?php
echo "Your order number is :".$order_number;
?>
</td>
</tr>

<tr align="center">
<td>Thank you for booking, We will contact you soon ! </td>
</tr>
</table>
</body>
</html> 

On executing this program one extra row is being added every time. Please tell me what is the problem in this code? Also when I want to increase the value of column by 1 then it is increasing by 2..see- order_number=order_number+1;

No correct solution

OTHER TIPS

<?php
    error_reporting(E_ALL);
    ini_set('display_errors', true);

    $host           = "localhost";
    $user_name      = "usr";
    $pwd            = "pwd";
    $database_name  = "db"; //assuming you created this

    mysql_connect($host, $user_name, $pwd)or die(mysql_error());
    mysql_select_db($database_name)or die(mysql_error());

    $datee              = $_POST['datee'];
    $time               = $_POST['time'];
    $destination        = $_POST['destination'];
    $days               = $_POST['days'];
    $cab                = $_POST['cab'];
    $route              = $_POST['route'];
    $full_name          = $_POST['full_name'];
    $address            = $_POST['address'];
    $mobile_number      = $_POST['mobile_number'];
    $pickup_location    = $_POST['pickup_location'];

    $query2 = "SELECT order_number FROM `count` WHERE 1";
    $countQuery = mysql_query($query2)or die(mysql_error());

    while($row = mysql_fetch_array($countQuery))
    {
        $variable = $row["order_number"];
    }

    $query3 = "UPDATE `count` SET `order_number` = ''".$order_number."'+ 1 WHERE 1";
    mysql_query($query3)or die(mysql_error());

    $query1="INSERT INTO booking VALUES ('".$datee."','".$time."','".$destination."','".$days."','".$cab."','".$full_name."','".$address."','".$mobile_number."','".$pickup_location."','".$route."','".$variable."')";
    mysql_query($query1)or die(mysql_error());
?>

I have updated your question's code here try it and they see it's work.

Do not forget to create $order_number variable.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top