MySQL Forums
Forum List  »  PHP

How to set Dynamic WHERE CONDITIONS to show customer rows depending on Login using PHP?
Posted by: Mrkey Lee
Date: March 10, 2013 02:41AM

I have two tables in MYSQL, tblLogin and tblCustomers with the following Columns: tblLogin{LoginID as Primary_Key, UserName, Password} and tblCustomer{Customer_ID as Primary_Key, Customer_FullName, OrderID, OrderDetails, submission_date, Customer_LoginID as Foreign_key}.
What I want is to let customers to view their own records only due to their login information.
To accomplish this I set two forms namely Login_Form.php and Results.php where after pressing SUBMIT BUTTON of Login_Form.php the user should be able to see his own records displayed on Results.php form dynamically.
Here is my code for these forms!
1. Login_form.php
//Begin Login_Form.php
<meta content="text/html; charset=ISO-8859-1"
<form target="_self" enctype="text/plain" method="post"
action="Results.php" name="Login_Form"><label>User
name</label> &nbsp;
<label>Password<br> <br> </label><input name="UserName" value="User Name">
&nbsp;<input name="Password" value="Password"
&nbsp; &nbsp; <input name="Submit" value="submit"
//End Login_Form.php

2. Results.php
//Begin results.php
$dbhost = 'localhost:3306';
$dbuser = 'root';
$dbpass = 'rootpassword';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
die('Could not connect: ' . mysql_error());
$sql = 'Customer_ID, Customer_FullName, OrderID, OrderDetails,submission_date, Customer_LoginID WHERE {...YOUR HELP IS NEEDED PLEASE....?}';

$retval = mysql_query( $sql, $conn );
if(! $retval )
die('Could not get data: ' . mysql_error());
while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
echo "Customer_ID :{$row['Customer_ID']} <br> ".
"Full Name: {$row['Customer_FullName']} <br> ".
"Order Details: {$row['OrderDetails']} <br> ".
"Date : {$row['submission_date']} <br> ".
echo "Fetched data successfully\n";
//End results.php

Now how to fetch specific data due to specific customer?
Any hint would be highly appreciated

Options: ReplyQuote

Written By
How to set Dynamic WHERE CONDITIONS to show customer rows depending on Login using PHP?
March 10, 2013 02:41AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.