tonypoli783 Posted October 8 Share Posted October 8 (edited) I try this code but submit button non work. any help ? pls. echo "<form method=post action=#>"; while($row = mysqli_fetch_assoc($result)) { echo"<center>".$row["data"]." ".$row["time"]."<br>"; echo $row["country"]." ".$row["lega"]."<br>"; echo "".$row["team1"]."[".$row['pos_t1']."]vs".$row["team2"]."[".$row['pos_t2']."]<br>"; echo "<input type=checkbox value=".$row['team1']." name=team1"; } echo"<input type=submit value=submit></form>"; Edited October 8 by tonypoli783 Quote Link to comment https://forums.phpfreaks.com/topic/324700-php-update-mysql-database-with-formcheckbox/ Share on other sites More sharing options...
Barand Posted October 8 Share Posted October 8 Telling us that some thing isn't working tells us nothing. What should happen that isn't? What shouldn't happen that is? Your topic title mentions a database update. Where and what is that code? NOTE - use the code button (<>) when posting code. Quote Link to comment https://forums.phpfreaks.com/topic/324700-php-update-mysql-database-with-formcheckbox/#findComment-1637180 Share on other sites More sharing options...
Phi11W Posted October 9 Share Posted October 9 8 hours ago, tonypoli783 said: I try this code but submit button non work. any help ? pls. echo "<form method=post action=#>"; while($row = mysqli_fetch_assoc($result)) { echo"<center>".$row["data"]." ".$row["time"]."<br>"; echo $row["country"]." ".$row["lega"]."<br>"; echo "".$row["team1"]."[".$row['pos_t1']."]vs".$row["team2"]."[".$row['pos_t2']."]<br>"; echo "<input type=checkbox value=".$row['team1']." name=team1"; } echo"<input type=submit value=submit></form>"; Short answer: Your HTML is incorrect. You're missing the closing '>' on the Checkbox's input element. I'd also recommend using quotes on HTML attributes. The cases where you need them far outnumber those where you can get away without them. I'd suggest something more like this: echo '<form method="post" action="#">'; while( $row = mysqli_fetch_assoc( $result ) ) { printf( '<center>' . '%1$s %2$t<br>' . '%3%s %4$s<br>' . '%5$s[%6$s] vs %7$s[%8$s]<br>' . '<input type="checkbox" value="%5$s" name="team"> . '</center>' , $row['data'] , $row['time'] , $row['country'] , $row['lega'] , $row['team1'] , $row['pos_t1'] , $row['team2'] , $row['pos_t2'] ); echo '<input type="submit" value="submit"></form>'; Regards, Phill W. Quote Link to comment https://forums.phpfreaks.com/topic/324700-php-update-mysql-database-with-formcheckbox/#findComment-1637200 Share on other sites More sharing options...
mac_gyver Posted October 9 Share Posted October 9 the current markup will only submit the last checkbox value that is checked. to submit a set of values, the form field name needs to be an array, e.g. name='team[]' you also need to apply htmlentities() to dynamic values being output in a html context so that any html entity in a value, such as a ', cannot break the markup. Quote Link to comment https://forums.phpfreaks.com/topic/324700-php-update-mysql-database-with-formcheckbox/#findComment-1637201 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.