Hi,
I programmed a shopping card and I am encountering the following problem now. I already looked for answers on various forums. I am a Beginner at php4/mysql.
ok ...
Well, the script get all the articles and prices from the database and lists them in a table. The numer of articles is displayed in an input box so that the user can update the numer for each article. and the have the total amout recalculated.
And that is exactly my problem. If the user changes more than one value and clicks on "update" then how do I program this?
Thank you very much for ANY help on this. I am desperate since I need this info for work and I am really stuck.
Compu
Problem with Shopping Cart for Online Shop - Help!!! :-)
Moderator: General Moderators
-
compuboy1010
- Forum Newbie
- Posts: 1
- Joined: Thu Aug 29, 2002 5:04 pm
Where you are listing al the products or aticels, you have to make an form of it.
The form action must be an other php page, wher you are sending the variables of every colm input type=text name="colm1" or somthing like that.
when you klick on submit the variables have been send to the php page you setted in the action <form action="update.php" method=post> or somthing like this.
$Host = "localhost";
$Gebruiker = "user name";
$Wachtwoord ="password";
$DBNaam ="Your database name";
$TabelNaam ="Your table name";
$connetion = mysql_connect ($Host, $Gebruiker, $Wachtwoord);
Then you have to read out the variables in update.php you can do that with $_POST=['colm1'] etc.
And finaly you can send them to the database.
don't forget to make a $connection variable with your username etc. etc.
Then write this
$Update = Insert into $TABLE NAME values ('0[only if auto_increment]','$_POST[colm1]','$_POST[colm2]','$_POST[colm3]')"; etc.
if (mysql_db_query ($DBNaam, $Opdracht, $Verbinding) ) {
print ("<font face=\"verdana\" size=1 color=\"white\">The database has been updated<br></font>\n");
} else {
print ("<center><br><br><br>The database hasn't been updated<br>\n");
}
mysql_close ($Verbinding);
The form action must be an other php page, wher you are sending the variables of every colm input type=text name="colm1" or somthing like that.
when you klick on submit the variables have been send to the php page you setted in the action <form action="update.php" method=post> or somthing like this.
$Host = "localhost";
$Gebruiker = "user name";
$Wachtwoord ="password";
$DBNaam ="Your database name";
$TabelNaam ="Your table name";
$connetion = mysql_connect ($Host, $Gebruiker, $Wachtwoord);
Then you have to read out the variables in update.php you can do that with $_POST=['colm1'] etc.
And finaly you can send them to the database.
don't forget to make a $connection variable with your username etc. etc.
Then write this
$Update = Insert into $TABLE NAME values ('0[only if auto_increment]','$_POST[colm1]','$_POST[colm2]','$_POST[colm3]')"; etc.
if (mysql_db_query ($DBNaam, $Opdracht, $Verbinding) ) {
print ("<font face=\"verdana\" size=1 color=\"white\">The database has been updated<br></font>\n");
} else {
print ("<center><br><br><br>The database hasn't been updated<br>\n");
}
mysql_close ($Verbinding);