PHP Display data inside a table and image display?

  • Thread starter Thread starter Mr E
  • Start date Start date
M

Mr E

Guest
i'm unsure as to how to do the following things

1) post an image from one page to the next using session variables and the $_POST method

2) display my information inside a table to present the information better.

for background information to help assist, my website i'm scripting uses an SQL database to store prices and image for products (doors). the database does not actually hold the image, it just holds the name of the image and my script does the rest.

the script below is what i have, the first script is one of the product pages. this has a hidden variable input field for the image as i simply don't know what to put

the second is the shopping basket page that will hold all the information. it has a session variable for the image, however it obviously does not display anything.

this is the order script

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



// gathers the door name the final price and the thumbnail for all doors that have Arbury in their name
$sql = mysql_query("SELECT DoorName, Thumbimage,OurListPrice,ListPrice50Percdisc, VAT, InternetDiscount10Perc FROM tblpricelist WHERE DoorName like '%Arbury%'");

$cln = 0;
echo ("<table>");
echo ("<tr>");
while ($row = mysql_fetch_array($sql))
{
echo ("<th align=\"center\">");

$id = $row['DoorName'];
echo '<form action="basket.php" method="post">';
echo " <img src='./thumb/". $row['Thumbimage']."' onclick=\"this.src='./large/". $row['Thumbimage']."'\" ondblclick=\"this.src='./thumb/". $row['Thumbimage']."'\"/><br />";
echo $row['DoorName']."<br/>";
echo "full price: £".$row['OurListPrice']."<br/>";
echo "50% discount: £". $row['ListPrice50Percdisc']."<br/>";
echo "We pay the VAT: £". $row['VAT']."<br/>";
echo "and with our online discount you will pay: £".$row['InternetDiscount10Perc']."<br/>";
echo "Quantity:";
echo "<input type='hidden' name='DoorName' value='".$row['DoorName']."'>";
echo "<input type='hidden' name='price' value='".$row['InternetDiscount10Perc']."'>";
echo "<INPUT type='text' name='Quantity' value='1' size=2 maxlength=2>";
echo "<input type='submit' id='Submitfrm' value='order now' />";
echo "</form>";


echo "</th>";

$cln++;
if ($cln == 4)
{
$cln = 0;
echo ("</tr>\n<tr>");
}
}


echo ("</tr>");
echo ("</table>");

______________________________________________________

this is the script for the shopping basket page

<?php
// store session data
session_start();
$quantity=$_POST["Quantity"];
$doorname=$_POST["DoorName"];
$price=$_POST["price"];
$image=$_POST["image"];

$_SESSION [$doorname]= $quantity. "+" . $price. "+" . $image ;

?>



the above are the session variables


<?php




foreach ($_SESSION as $key=>$val)
{
$index = stripos($val, "+");
$quantity = substr($val, 0, $index);
$price = substr($val,$index+1);
$image = substr($val,$index+2);
echo "Door type $key has quantity $quantity and price £$price <br />";
}

?>

this is what i've got so far.

as you currently can see it displays the values as a text string rather than in a table.

the main problem is holding the image in the hidden Input field, as i'm not sure how to do that with the script i have.
 
Back
Top