Jump to content

kah

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

kah's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanx for your help nogray and ken. I have partially resolved it, but have decided that I am going to do have to learn more about sessions if I am to complete this project properly. Ken I would appreciate any direction you can give in reducing the code. ta, kah
  2. Hi. I am attempting to build a very simple shopping cart using php for an assignment. I am displaying the images and relevant details for the product from a MYSQL database. I want the customer to be able to select as many products as they wish, and then click the Purchase button which will take them to shop_cart.php. This page will display the products they have chosen. I cannot work out how to display the chosen products in shop_cart.php. I have included the functions for first page - shop_didge() - and then the display - page shop_cart(). Where I want the id to display the id of sb1253 I get a:3:{i:0;s:6:"sb1253";} and $timber displays N; whereas it should be Stringy Bark. Appreciate any help. <?php } function shop_didge(){ ?> <form action="shop_cart.php" method="post"> <table class='table9' align='center'> <?php // Get all the data from the "products" table $result = mysql_query("select * from products where SOLD=''") or die(mysql_error()); // keeps getting the relevant info until there are no more to get while($col = mysql_fetch_array( $result )) { echo "<tr><td colspan='2'><strong>Didge ID: "; echo $col['productid']; echo "</strong></td></tr><tr><td colspan='2'><img class='image' src='images/"; echo $col['longimage']; echo "' />"; echo "</td><tr><td><img class='image' src='images/"; echo $col['mouthimage']; echo "' /></td><td rowspan='2'>"; echo "<table class='table10'>"; echo "<tr><td>Timber:</td>"; echo "<td>"; echo $col['timber']; echo "</td></tr><tr>"; echo "<td>Length:</td><td>"; echo $col['length']; echo "cm</td></tr><tr>"; echo "<td>Mouth:</td><td>"; echo $col['mouth']; echo "cm</td></tr><tr>"; echo "<td>End:</td><td>"; echo $col['end']; echo "cm</td></tr><tr>"; echo "<td>Weight:</td><td>"; echo $col['weight']; echo "kg</td></tr><tr>"; echo "<td>Key:</td><td>#"; echo $col['key']; echo "</td></tr><tr>"; echo "<td>Soundfile:</td><td><a href='"; echo $col['soundfile']; echo "'>"; echo $col['soundfile']; echo "</a></td></tr><tr>"; echo "<td>Price:</td><td>$"; echo $col['price']; echo "</td></tr><tr>"; echo "<td>Purhase:</td>"; //edit if wrong echo "<td><input name='id[]'"; echo $col['productid']; echo "' type='checkbox' value='"; echo $col['productid']; echo "'></td>"; echo "</tr></table>"; echo "</td></tr>"; echo "<tr><td><img class='image' src='images/"; echo $col['endimage']; echo "' /></td></tr>"; echo "<tr><td colspan='2'><hr /></td></tr>"; echo "$productid"; } ?> <tr> <td colspan="2" align="right"><input type="submit" name="purchase" value="Purchase" /></td> </tr> </table> </form> //Display page <?php } function shop_cart(){ ?> <?php $id=serialize($_POST['id']); $timber=serialize($_POST['timber']); // tried $id=$_POST['id']; only displayed Array ?> <table class="table9" align="center"> <tr> <td>Product ID</td> <td>Description</td> <td>Price</td> </tr> <?php echo '<tr><td>'; echo $id; echo '</td></tr><tr><td>'; echo $timber; echo '</td></tr>'; ?> </table>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.