| | |
simple shoping cart problem!
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2009
Posts: 15
Reputation:
Solved Threads: 0
hi guys, i have working on this simple cart script,it goes like when selecting the product in combobox it will display the details of the
product into the textbox, i can display the details but my problem is when i select another product the previous
selected product was replaced.. what should i do to keep the selected first,second.. and so on product in the form? thanks
my script so far...
product into the textbox, i can display the details but my problem is when i select another product the previous
selected product was replaced.. what should i do to keep the selected first,second.. and so on product in the form? thanks
my script so far...
<html>
<head>
</head>
<body>
<form action="insert.php" method="post">
<?php
mysql_connect("localhost","root","");
mysql_select_db("Inventory") or die(mysql_error());
$sql="SELECT * FROM product order by id";
$query=mysql_query($sql);
echo "<select name='select' size='5'>";
while($row = mysql_fetch_array($query))
{
if ($_POST['select'] == $row['id']){
$pquan=$row['pquan'];
$sel=$row['sellprice'];
$pcode = $row['pcode'];
}
$selected = '';
if (isset($_POST['select']) && strcmp($row['id'], $_POST['select']) == 0)
{
$selected = ' selected="selected"';
}
printf ('<option value="%s"%s>%s</option>'. PHP_EOL, $row['pname'], $selected, $row['pname']);
}
echo "</optgroup>";
?>
</select>
<?php
if ($_POST['submit'])
{
$i = $_POST['count'];
for ($x=0;$x<=$i;$x++)
{
?>
<br>
<input type="text" name="textbox<?php echo $x; ?>" value="<?php echo htmlspecialchars(@$_POST['select']); ?>" size=5/>
<input type="text" name="textbox<?php echo $x; ?>" value="<?php echo $pcode ?>" size=5/>
<input type="text" name="textbox<?php echo $x; ?>" value="<?php echo $pquan ?>" size=5/>
<input type="text" name="textbox<?php echo $x; ?>" value="<?php echo $sel ?>" size=5/>
<input type="text" name="textbox<?php echo $x; ?>" size=5/>
<input type="submit" name="delete" value="Delete" />
<?php
}
$i++;
?>
<input type="hidden" name="count" value="<?php echo $i; ?>" />
<?php
}
else
{
?>
<input type="hidden" name="count" value="0" />
<?php
}
$i--
?>
<br>
<input type="submit" name="submit" value ="Add Text Box" />
</form>
</body>
</html>•
•
•
•
what should i do? should i change that lines? please help im so confused
**********
I am referring to the line
•
•
•
•
$selected
Last edited by tiger86; Aug 17th, 2009 at 12:21 am. Reason: Needed to be more specific!
If I helped you I would appreciate it if you would give me some reputation.
Follow the new Social Network Planet Zuda On twitter. Planet Zuda should go live sometime in 2010.
Follow the new Social Network Planet Zuda On twitter. Planet Zuda should go live sometime in 2010.
•
•
Join Date: Apr 2009
Posts: 257
Reputation:
Solved Threads: 37
use LIST or Array of your products so you can manage the previous product information with next one.
![]() |
Similar Threads
- Simple PHP Cart (PHP)
- mock shopping cart problem (PHP)
- Shopping cart (PHP)
- Shopping cart problem (PHP)
- windows xp shopping cart problem (Windows NT / 2000 / XP)
- Simple Shopping Cart with arrays (PHP)
- my cart problem (PHP)
- php shoping cart (PHP)
- Simple answer for vexing problem? (OS X)
Other Threads in the PHP Forum
- Previous Thread: Need help with script
- Next Thread: issues with isset and $_GET
Views: 366 | Replies: 8
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic echo email error execution file files folder form forms function functions google href htaccess html htmlspecialchars image include insert integration ip java javascript joomla jquery limit link links login loop mail menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote replace script search select server session sessions sms soap source space speed sql structure syntax system table tutorial update updates upload url validation validator variable video web xml youtube





