| | |
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.
read my actionscript to english blog
Currently developing what should be social network 2.0 offline.
read my actionscript to english blog
Currently developing what should be social network 2.0 offline.
•
•
Join Date: Apr 2009
Posts: 254
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
| Thread Tools | Search this Thread |
# 5.2.10 alexa apache api array beginner binary broken cakephp checkbox class clean clients cms code cron curl database date directory display dissertation dynamic echo echo$_get[x]changingitintovariable... email encode error fairness file files folder form forms function functions google href htaccess html image images include indentedsubcategory insert ip javascript joomla legislation limit link local login mail memberships menu mlm multiple multipletables mysql mysqlquery newsletters oop open paypal pdf persist php problem provider query radio random recursion remote rss script search server sessions simple sms sockets source space spam sql syntax system table tutorial update upload url validator variable video web youtube





