Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to insert multiple checkbox value respect their id
    primarykey
    data
    text
    <p>I fetch some value from database. and want to update the database table respect their ids.</p> <p>here is my code: </p> <pre><code>&lt;?php $sql = "SELECT * FROM tbl_ads ORDER BY ads_id DESC LIMIT $START, $LIMIT"; $result = mysql_query( $sql ); $num = mysql_num_rows( $result ); if( $num &gt; 0 ){ while( $row = mysql_fetch_array( $result ) ){ ?&gt; &lt;tr bgcolor="#E1E1E1"&gt; &lt;td align="left" valign="top" bgcolor="#F1F1F1" class="BlackText2"&gt; &lt;?php echo $row['title'];?&gt; &lt;/td&gt; &lt;td align="left" valign="top" bgcolor="#F1F1F1" class="BlackText2"&gt; &lt;?php echo substr($row['description'], 0, 40);?&gt; &lt;/td&gt; &lt;td align="left" valign="top" bgcolor="#F1F1F1"&gt; &lt;?php echo $row['mywebsite'];?&gt; &lt;/td&gt; &lt;td align="center" valign="top" bgcolor="#F1F1F1"&gt; &lt;input type="hidden" name="ads_id[]" value="&lt;?php echo $row['ads_id'];?&gt;"&gt; &lt;input type="checkbox" name="feature[]" value="feature"&gt; &lt;/td&gt; &lt;?php if( isset( $_REQUEST['submit'] ) ){ $feature = $_POST['feature']; $ads_id = $_REQUEST['ads_id']; if( empty( $feature ) ){ echo( "You didn't select any buildings." ); }else{ $N = count( $feature ); $M = count( $ads_id ); echo("You selected $N door(s): "); for( $i=0 ; $i &lt; $N ; $i++ ){ for( $j=0 ; $j &lt; $M ; $j++ ){ echo ( $feature[$i] . " " ); echo $update_feature = "UPDATE tbl_ads SET `featureads` = '".$feature[$i]."' WHERE ads_id ='".$ads_id[$j]."'"; $result_feaure = mysql_query($update_feature); } } } } ?&gt; </code></pre> <p>but my problem is when I update the featureads column respect ads_id column then all column are selected.</p> <p>how to solve this problem? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload