php - UP dating the count from a user making a section from a drop down menu -
hi have mysql database called colordb , table in database called colorchoic 3 rows call id, color , value. color row has 8 colors stored in yellow, blue, green, red, black, orange, brown, white. have php select populate select form pulling colors database. know if there anyway of getting user select color add 1 value row. instance if 6 users select favorite color database might table below.
the table/database before 6 users select inputs (colors).
**color value** orange 0 red 0 blue 0 black 0 yellow 0 green 0 white 0 brown 0
the table/batabase after 6 users select input (colors)
**color value** orange 0 red 2 blue 1 black 1 yellow 1 green 1 white 0 brown 0
this php code
<?php // create db connection $con = mysqli_connect ("localhost", "user", "password", "colorbd"); // check connection if ($con === false){ die ("error: not connect database." . mysqli_connect_error ()); } $sql = "select color colorchoice"; $result = $con->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "color: " . $row["color"]. " <br>"; } } else { echo "0 results"; } mysqli_close($con);
?>
so i'm trying allow user select color select add 1 value row each time user selects color.
Comments
Post a Comment