<form method="post" action="server.php">
<?php include('errors.php'); ?>
<?php $db = mysqli_connect('localhost', 'root', '', 'dbai');// Establishing Connection with Server..
$qery2= "SELECT * FROM stock ";
$produit=mysqli_query($db, $qery2);
?>
<div class="input-group">
<label>Designation</label>
<select name="desi">
<?php
while($rang=mysqli_fetch_assoc($produit))
{
$designat= $rang['designation'];
?>
<option name ="" value=" <?php echo $designat;?>"><?php echo $designat; ?></option>
<?php }; ?>
</select>
<input type="text" name="designated" value="<?php echo $_POST['desi']; ?>" readonly>
</div>
<div class="input-group">
<label>Quantité cartons</label>
<input type="text" name="quantitt" value="<?php echo $quantitt ; ?>">
</div>
<div class="input-group">
<button type="submit" class="btn" name="reg_ar">Enregister produit</button>
</div>
</form>
//php code to be executed when button clicked:
if (isset($_POST['reg_ar'])) {
// receive all input values from the form
$designate=$_POST['desi'];
$quantitt = mysqli_real_escape_string($db, $_POST['quantitt']);
$quantitu = mysqli_real_escape_string($db, $_POST['quantiu']);
$quantitp = mysqli_real_escape_string($db, $_POST['quantip']);
$prixt = mysqli_real_escape_string($db, $_POST['prixt']);
$prixu = mysqli_real_escape_string($db, $_POST['priu']);
$prixp = mysqli_real_escape_string($db, $_POST['prip']);
// form validation: ensure that the form is correctly filled ...
// by adding (array_push()) corresponding error unto $errors array
if (empty($designate)) { array_push($errors, "designation is required"); }
if (empty($quantitt)) { array_push($errors, "quantitt is required"); }
// first check the database to make sure
// a user does not already exist with the same username and/or email
// Finally, register user if there are no errors in the form
if (count($errors) == 0) {
$query0="SELECT * FROM stock WHERE designation= '$designate' ";
$alt0= mysqli_query($db, $query0);
$query2= "UPDATE stock SET quantitt='$quantitt' WHERE designation= '$designate'";
mysqli_query($db, $query2);
header('location: index.php');
}
}
What happens is the the “WHERE” in mysql statement does not read the input from the select tag , it works fine if I type some input , but not if i want it to get it from select tag. some helps would be much appreciated because to me everything looks fine yet its not working it’s driving me nuts. thanks