king-ich
Mitglied
Die Anzahl.Welche Zahl?!
Meinst Du die 0.33?! Falls ja musst Du den String durchsuchen und dann entsprechend ersetzen
Ich meine 1.
Und wie durchsuche ich den String und ersetze entsprechend?
Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature currently requires accessing the site using the built-in Safari browser.
Die Anzahl.Welche Zahl?!
Meinst Du die 0.33?! Falls ja musst Du den String durchsuchen und dann entsprechend ersetzen
<form method="post" action="action.php">
<?php foreach($warenkorb as $id => $artikel): ?>
<input type="number" name="anzahl[<?php echo (int) $id ?>]" min="0" max="100" step="1" value="<?php echo (int) $artikel['Anzahl'] ?>" />
<?php endforeach; ?>
<input type="submit" name="change" value="Aktualisieren" class="aktualisieren">
</form>
<?php
session_start();
if(isset($_POST['change'])){
$warenkorb = $_SESSION["warenkorb"];
$anzahl = $_POST['anzahl'];
foreach ($anzahl as $id => $num) {
if(array_key_exists($id, $warenkorb)) {
$warenkorb[$id]['Anzahl'] = $num;
}
}
$_SESSION['warenkorb'] = $warenkorb;
}