Hi everyone!
I've just started learning php a while back and I am having a problem figuring this out. I've spent days searching for a solution but I think I don't know the correct terms etc...
I have a form that submits to a php page with the amounts of products, the generated data retrieved from the mysql database (id, supplier, product_name) displays perfectly inside a table. If I try to assign the information retrieved from the database to a variable, the variable is returned blank or as 1.
So how can store this information(table with retrieved data) and send it via email?
<html>
<body bgcolor="#333333" style="color:white; font-family:Verdana, Geneva, sans-serif;" >
<table border="1" bordercolor="#000000" bgcolor="#00FFFF" style="color:black" width="985px">
<tr>
<th width="300px">Product</th>
<th width="300px">Part #</th>
<th width="300px">Supplier</th>
<th>Amount</th>
</tr>
<?
$host = "localhost";
$user = "root";
$pass = "";
$database = "products";
$linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host.");
mysql_select_db($database, $linkID) or die("Could not find database.");
$query = "SELECT * FROM products ORDER BY supplier, product";
$resultID = mysql_query($query, $linkID) or die("Data not found.");
while($row = mysql_fetch_array($resultID))
{
$fok = $row['id'];
$amount = $_POST[$fok] . "</td>";
if ($amount != 0) {
echo "<tr><td>";
echo $row['Product'] . "</td><td>";
echo $row['Part_Number'] . "</td><td>";
echo $row['Supplier'] . "</td><td>";
echo $amount;
echo "</tr>";
}
}
echo "</table>";
?>
</html>
This file is included in a submit.php file.
If the inc file is set as a variable and displayed again, it displays "1".
$to = "admin@email.com";
$headers = "From: orders@email.com";
$subject = "Order from " . - $_POST['Name'];
$name_field = $_POST['Name'];
$surname_field = $_POST['Surname'];
$tel_field = $_POST['Tel'];
$info_field = $_POST['Info'];
$address_field = $_POST['Address'];
$inc = include( 'inc.php' );
$body = "From: $name_field\n $surname_field\n Email: $email_field\n Tel: $tel_field\n Information:\n $info_field Products:\n $inc;";
$thanks = "Thank you for using our online order system! We are processing your order and will get back to you soon!";
echo "<br>";
echo "<br>";
echo "Order has been submitted";
echo "<br>";
echo "<br>";
mail($to, $subject, $body, $headers);
mail($email_field, $subject, $thanks, $headers);
echo $inc;
The $inc variable at the bottom of the file still displays incorrectly. The $inc doesn't show the data retrieved from the mysql database. It only displays when the file is included, it only shows the data once, it is not stored in the variable, why? Should I use xml?