0

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

3
Contributors
10
Replies
11
Views
8 Years
Discussion Span
Last Post by justinmyoung
0

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.

0

What are the columns in the database?

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

0

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'];
}
0

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.

0

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

0

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>
0

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.

0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.