Hi,
I have had some good fortune on this site so I am back and I must iterate I am a beginer.
I am having some problems getting to grips with the right technique to manage variables and adding a unique order number to a customer order form.
I have 4 stages to my order form.
Stage 1 involves the user selecting a link based on what they want. The link then sets 2 variables. $type and $fault based on the link they have chosen.
In stage 2 I have used
[PHP]
<?php
$type = $_GET['$type'];
$fault = $_GET['$fault'];
?>
[/PHP]
and echo these details on the order form (in a read only input box to make sending them on easier, well for me anyway) and this works fine.
Would I still need to do this if I used sessions to handle my variables.
In stage 2 the user then has to fill in their details on a form and submit the from. I have used post as the action.
In stage 3 all the details are displayed correctly.
It is here where my problem really exists.
I want to add a unique order number, I have done this for the first order but cant get the order number to then auto increment. I have all the tables set up and am connecting to them fine.
The code for this is as follows
[PHP] <?php
$sql="SELECT * FROM i_counter"; // This table manages the incrementing counter. It contains 1 row called cnt.
$result=mysql_q uery($sql,$db);
$row = mysql_fetch_arr ay($result);
$cnt= $row["cnt"];
$cnt++;
$order_id="IPRD " . $cnt; //prefixes the order number with company ID
// Update counter for order id's
$sql = "UPDATE i_counter SET cnt = $cnt";
$result = mysql_query($sq l);
// Add a new temp database entry
$sql = "INSERT INTO i_orders (id, ordernumber) VALUES ('', '$order_id')";
$result = mysql_query($sq l);
?>
[/PHP]
The code is currently sitting at the start of my file just after 2 include statements, one for db connection and the other for the page header.
Though I will probably more on to sessions soon the issue I really need help with is the auto incremneting order number.
Many thanks
I have had some good fortune on this site so I am back and I must iterate I am a beginer.
I am having some problems getting to grips with the right technique to manage variables and adding a unique order number to a customer order form.
I have 4 stages to my order form.
Stage 1 involves the user selecting a link based on what they want. The link then sets 2 variables. $type and $fault based on the link they have chosen.
In stage 2 I have used
[PHP]
<?php
$type = $_GET['$type'];
$fault = $_GET['$fault'];
?>
[/PHP]
and echo these details on the order form (in a read only input box to make sending them on easier, well for me anyway) and this works fine.
Would I still need to do this if I used sessions to handle my variables.
In stage 2 the user then has to fill in their details on a form and submit the from. I have used post as the action.
In stage 3 all the details are displayed correctly.
It is here where my problem really exists.
I want to add a unique order number, I have done this for the first order but cant get the order number to then auto increment. I have all the tables set up and am connecting to them fine.
The code for this is as follows
[PHP] <?php
$sql="SELECT * FROM i_counter"; // This table manages the incrementing counter. It contains 1 row called cnt.
$result=mysql_q uery($sql,$db);
$row = mysql_fetch_arr ay($result);
$cnt= $row["cnt"];
$cnt++;
$order_id="IPRD " . $cnt; //prefixes the order number with company ID
// Update counter for order id's
$sql = "UPDATE i_counter SET cnt = $cnt";
$result = mysql_query($sq l);
// Add a new temp database entry
$sql = "INSERT INTO i_orders (id, ordernumber) VALUES ('', '$order_id')";
$result = mysql_query($sq l);
?>
[/PHP]
The code is currently sitting at the start of my file just after 2 include statements, one for db connection and the other for the page header.
Though I will probably more on to sessions soon the issue I really need help with is the auto incremneting order number.
Many thanks
Comment