Ok to let you know im a newbie at this PHP coding.
Im having a problem with my PHP script that i have. What im Trying to Accomplish is when i go to a specific page i want orders only associated to the person looking at them. example: Person A Logs in and Sees Person A's Orders not Person B's.
this is the code i got for listing out the orders
<?php
echo "<html>
<head>
<title>Order List For $BillName</title>
</head>
<body>";
?>
<?
include("header.php");
?>
<?php
function my_conn() {
/* set's the variables for MySQL connection */
$server = "localhost"; // this is the server address and port
$username = "user"; // change this to your username
$password = "pass"; // change this to your password
/* Connects to the MySQL server */
$link = @mysql_connect ($server, $username, $password) or die (mysql_error());
/* Defines the Active Database for the Connection */
if (!@mysql_select_db("db", $link)) {
echo "<p>There has been an error. This is the error message:</p>";
echo "<p><strong>" . mysql_error() . "</strong></p>";
echo "Please Contact Your Systems Administrator with the details";
}
return $link;
}
function orderlist() {
$conn = my_conn();
$sql = "SELECT * FROM orders WHERE (BillName = $BillName)";
$result = mysql_query($sql, $conn);
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
?>
<?
echo "<table>
<tr>
<td>PO</td>
<td>BillName</td>
</tr>";
?>
<?
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo("<tr>\n<td>" . $row["PO"] . "</td>");
echo("<td>" . $row["BillName"] . "</td>");
echo("<td><a href=\"" . $_SERVER['PHP_SELF'] . "?PO=" .$row['PO'] . "&Submit=Edit\">Edit</a></td></tr>\n\n");
}
}
?>
</table>
</body>
</html>
Now my problem is that my header prints out and everything but i get no information, No tables, Nothing. This eventually is going to be tied into a login script that will ask for the username and password i have in the database and show only the orders of theperson that just logged in.
Any help with what im doing wrong please advise me.
thank you in advance.