Hi,

I'm trying to write a script to allow a customer to access the status of their order. I have set up the database properly, including all the fields necessary. I have successfully written a registration script, allowing the customer to register his/her details into the database, but where I'm struggling is making the query for a customer with a job number (who enters first and last name, and his/her job number) the ability to access information from the database that shows their status.

I guess the question is how do I query a field (job number) to return multiple fields (i.e. the status of their repair).

Thanks

Recommended Answers

All 10 Replies

The point is, how you are storing the data in the table. select repair_status from table where job_number = '123' will display (the list) of repair_status for job_number 123.

What are the columns in the database?

Will the end-user be tracking their order based on an ID?

You could use a structure like

jobID, customer_name, status, job_type, date

You would then use

$query = "SELECT * FROM repairs WHERE jobID = '999'";
$result = mysql_query($query);

while($row=mysql_fetch_array($result, MYSQL_ASSOC)){
echo 'Status for Job ID 999 is '.$row['status'];
}

the structure is: customer_id, first_name, last_name, job_number, email, date_received, date_proceeded, repair_charges, part_charges, date_shipped, total_sale, total_due, comments.

the customer uses his/her job number to access information from these various fields. So when the customer submits their First name, Last name, Job number, and email - I want the query to call up all the remaining fields (which represent the status).

So if the job number is the password, what kind of query would you suggest I need?

Thanks very much.

Check this tutorial. And here is an example how you can query your table..

I guess the problem I'm having is using the Job Number, when entered into the browser form, sends back all the information from the other fields (like repair_charges, total_sale, total_due, etc). The Job Number is therefore acting like a password.

The Where Clause doesn't seem to allow the Job Number to act as a password. All the customers information will already be entered in the database. All I need to due is call up the essential fields when they enter their job number.

thanks for your help, hopefully I'll understand it eventually

Umm.. you have one textbox to enter the job number ? When the user enters his job number and click on submit, all his details should be displayed ? Is that right ?
Here is an example.

<?php
if(isset($_POST['submit'])) {
	$jobnumber=$_POST['jobnumber'];
	//connect
	//selectdb
	$query = "select * from table where jobnumber='$jobnumber'";
	$result = mysql_query($query);
	while($row = mysql_fetch_array($result)){
		echo $row['columnname']; //allign it however you want to display
		echo $row['columnname1']; 
		//etc...
	}
}
?>
<html>
<body>
<form method="post" action="getjobnumber.php">
<input type="text" name="jobnumber"><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>

Hi again,

I seem like this is on the right track.

<?php
if(isset($_POST['submit'])) {
	$jobnumber=$_POST['job_number'];

	$con = mysql_connect("localhost","root","rilke123");
	if (!$con)
	  {
	  die('Could not connect: ' . mysql_error());
	  }

	mysql_select_db("parsec", $con);

	$query = "SELECT * FROM customers WHERE job_number='$jobnumber'";
	$result = mysql_query($query);
	while($row = mysql_fetch_array($result)){
		echo $row['first_name'];
		echo $row['last_name'];
		//etc...
	}
}
?>
<html>
<body>
<form method="post" action="getjobnumber.php">
<input type="text" name="jobnumber"><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>

But when I put in the job number in the text field, and it connects to the getjobnumber.php page, it comes up with a blank page. Why would that be?

Also, Thanks for your help on this; I'm probably getting annoying now.

I'm probably getting annoying now.

Lol.. Nah !

Anyway, if its connecting to getjobnumber.php page, what is the name of this page ? If this is a different page, put

$jobnumber=$_POST['job_number'];

$con = mysql_connect("localhost","root","rilke123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("parsec", $con);

$query = "SELECT * FROM customers WHERE job_number='$jobnumber'";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)){
echo $row['first_name'];
echo $row['last_name'];
//etc...
}

in getjobnumber.php page.

That works great! Thanks again for you help...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.