Jump to content

transfering data


Hellz

Recommended Posts

<td><"a href=cart.php?ProductId=$row[ProductId]">Add Item</a></td>

 

Im trying to get the above code to transfer data from one page to another. I have different items for sale on the sales page, the information comes from a database and i want it to transfer the data from a selected item onto the cart page.

 

I thought the above code would put a link on the sale page saying Add item at the end of each item information that has been brought from the database. Then when the user clicks on the link it will take them to the cart page and i then want it to display the information for the item they selected.

 

I was also wondering what the code would be that i would put on the cart page to show the information that i have transferred?

 

Any help would be greatly appreciated

Link to comment
Share on other sites

<?php

 

$dbc = mysql_connect ('bbp.webcontrolcenter.com','****','****') OR die('Could not connect to MySQL : ' . mysql_error() );

mysql_select_db ('***') OR die('Could not select the database : ' . mysql_error() );

 

 

$query = "SELECT * FROM item WHERE sale='yes'";

$result =  mysql_query ($query);

 

?>

<table>

  <tr>

    <td ><strong>Artist Name</strong></td>

    <td ><strong>Album Name </strong></td>

    <td ><strong>Price </strong></td>

    <td ><strong>Product Description</strong></td>

      <td ><strong>Image</strong></td>

          <td ><strong>Add to Basket</strong></td>

  </tr>

 

<?php

 

while($row = mysql_fetch_array($result,MYSQL_ASSOC))

{

Echo "<tr><td>$row[Artist]</td><td>$row[Album] </td><td>$row[Price]</td><td>$row[ProductDesc]</td><td><img src=$row[image] /><td><"a href=cart.php?ProductId=$row[ProductId]">Add Item</a></td>

</tr>\n";

 

}

mysql_close();

?>

 

</table>

 

^^ that is all my current code

 

Link to comment
Share on other sites

again, your quotes in the HTML are partially to blame, try:

<?php //.....
echo "<tr><td>$row[Artist]</td><td>$row[Album] </td><td>$row[Price]</td><td>$row[ProductDesc]</td><td><img src=$row[image] /><td><a href=\"cart.php?ProductId=$row[ProductId]\">Add Item</a></td>
</tr>\n";

//.... ?>

 

I moved the " in your <a> tag to after the href=  and then I \escaped it so it would screw up the quote marks that your echo statement is in

Link to comment
Share on other sites

<?php

 

$dbc = mysql_connect ('bbp.webcontrolcenter.com','****','****') OR die('Could not connect to MySQL : ' . mysql_error() );

mysql_select_db ('***') OR die('Could not select the database : ' . mysql_error() );

 

$Prodid = $_GET['ProductId'];

$query = "SELECT * FROM item WHERE ProductId=$Prodid

$result=do_query($query);

$row= mysql_fetch_array($result);

 

echo "Artist . " $row['Artist] . "<br/>";

echo "Album . " $row['Album'] . "<br/>";

 

?>

 

^^ Thats the code i got atm to show the result on the cart page but it does not work.

Link to comment
Share on other sites

$query = "SELECT * FROM item WHERE ProductId=".$Prodid;

 

Try that.  If $Prodid is not an integer, you need to surround it in single quotes:

 

$query = "SELECT * FROM item WHERE ProductId='$Prodid'";

 

You should also clean the input (the user can alter anything in the $_GET global array).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.