php - mysql update multiple column in multiple rows -


i trying update multiple data in both rows , columns in table client_id = '5' , invoice_number = '11'

my table tbl_particulars

my code:

         <table class="table table-bordered">              <tr>                <th>date</th>                <th>car no.</th>                <th>particulars</th>                <th>rate</th>                <th>amount</th>              </tr>              <?php        			        $sql = "select * tbl_particulars client_id = '5' , invoice_number = '11'";      $query = mysql_query($sql);      while($row = mysql_fetch_assoc($query)) {      ?>              <tr>                <td width="200px" nowrap="nowrap"><table>                    <tr>                      <td>from<br>                        <input type="hidden" name="numbers" value="3">                        <input type="hidden" name="ids[]" value="<?php echo $row['id'] ?>">                        <input type="text" name="date_from[]" value="<?php echo $row['date_from'] ?>" class="form-control" placeholder="dd/mm/yyyy"></td>                      <td>&ensp;</td>                      <td>to<br>                        <input type="text" name="date_to[]" value="<?php echo $row['date_to'] ?>" class="form-control" placeholder="dd/mm/yyyy"></td>                    </tr>                  </table></td>                <td width="100px"><input type="text" name="car_no[]" value="<?php echo $row['car_no'] ?>" class="form-control"></td>                <td width="250px"><table>                    <tr>                      <td><select name="particulars[]" class="form-control">                          <option value="">--please select ur duty--</option>                          <option value="local 80 kms. & 8.00 hrs. duty" <?php if($row['particulars']=="local 80 kms. & 8.00 hrs. duty") echo 'selected="selected"'; ?> >local 80 kms. & 8.00 hrs. duty</option>                          <option value="upto" <?php if($row['particulars']=="upto") echo 'selected="selected"'; ?>>upto</option>                          <option value="extra kms." <?php if($row['particulars']=="extra kms.") echo 'selected="selected"'; ?>>extra kms.</option>                          <option value="extra hrs." <?php if($row['particulars']=="extra hrs.") echo 'selected="selected"'; ?> >extra hrs.</option>                          <option value="local nights" <?php if($row['particulars']=="local nights") echo 'selected="selected"'; ?> >local nights</option>                          <option value="parking toll tax" <?php if($row['particulars']=="parking toll tax") echo 'selected="selected"'; ?> >parking toll tax</option>                          <option value="out station" <?php if($row['particulars']=="out station") echo 'selected="selected"'; ?> >out station</option>                        </select></td>                      <td style="vertical-align:text-top !important">&ensp; @ &ensp; </td>                      <td width="100px"><input type="text" value="<?php echo $row['quantity'] ?>" name="quantity[]" class="form-control"></td>                    </tr>                  </table></td>                <td width="80px"><input type="text" name="rate[]" class="form-control" value="<?php echo $row['rate'] ?>" onchange="calcgst()"></td>                <td width="80px"><input type="text" name="amount[]" class="form-control" value="<?php echo $row['amount'] ?>" onchange="calcgst()"></td>              </tr>              <?php } ?>              <tr>                <td colspan="5"><button type="submit" name="update_invoicee" class="btn btn-info">save & continue</button></td>              </tr>            </table>          </div>        </form>

my php script:

<?php if(isset($_post['update_invoicee'])){    $s = "update `tbl_particulars` set";  	for($i=0;$i<$_request['numbers'];$i++)  	{  		$s .="(  		date_from='".$_request['date_from'][$i]."',  		date_to='".$_request['date_to'][$i]."',  		car_no='".$_request['car_no'][$i]."',  		particulars='".$_request['particulars'][$i]."',  		quantity='".$_request['quantity'][$i]."',  		rate='".$_request['rate'][$i]."',  		amount='".$_request['amount'][$i]."' id='".$_request['ids'][$i]."'),";  	}  	$s = rtrim($s,",");  	if(!mysql_query($s))  		echo mysql_error();  	else  		echo "<script>alert('records updated')</script>";      } ?>

now script not work gives below error:

erreur de syntaxe pr�s de '( date_from='newvalue', date_to='newvalue', car_no='newvalue' � la ligne 1

the syntax error received due "(" symbol after set keyword. not allow set multiple statements more 1 set or in 1 query (mysql reference).

it possible put conditional expressions every field , concatenate query string received ids (some example). - 1 additional loop every field , complex code format query (think writing, debugging, reviewing , supporting in future).


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -