Jump to content

Update multiple rows with checkboxes / export selected to .txt


thaidomizil

Recommended Posts

Hello all,

 

i have a table that displays data from mysql, now i want to update multiple rows from that table with checkboxes, the value will basically just switch from 'new' to 'done' so far i have this:

 

<tbody>
                                        <tr class="first">
							        </tr>
									<?php
$ticketde=0;
while ($ticketde < $numpscde) {

$f1pscde=mysql_result($ticketresultde,$ticketde,"id");
$f2pscde=mysql_result($ticketresultde,$ticketde,"ticket");
$f4pscde=mysql_result($ticketresultde,$ticketde,"date");
$f5pscde=mysql_result($ticketresultde,$ticketde,"ip");
$f6pscde=mysql_result($ticketresultde,$ticketde,"done");

$setdone = ($f6pscde["done"] == 'n') ? "<a href=\"donepsc.php?id=".$f1pscde."\"><img src=\"ico_new.gif\" alt=\"new\" /></a>" : $f6pscde["done"];

if(isset($_POST['setdone'])){$checkbox = $_POST['checkbox'];

$id = "('" . implode( "','", $checkbox ) . "');" ;
$sql = "UPDATE ticket
        SET done='done'
        WHERE id='$f1pscde'";
$result = mysql_query($sql) or die(mysql_error());
}

?>

<tr class="first">
<td class="tc"><font face="Arial, Helvetica, sans-serif"><?php echo $f1pscde; ?></font></td>
<td class="tc"><font face="Arial, Helvetica, sans-serif"><?php echo $f2pscde; ?></font></td>

<td><font face="Arial, Helvetica, sans-serif"><?php echo $f4pscde; ?></font></td>
<td class="tc"><font face="Arial, Helvetica, sans-serif"><?php echo $f5pscde; ?></font></td>
<td class="tc"><font face="Arial, Helvetica, sans-serif"><?php echo $setdone; ?></font></td>
<td class="tc"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $f1pscde['id']; ?>"></td>


</tr>


<?php
$ticketde++;
}
?>
									</tbody>
								</table>
                                    <center><input type="submit" name="setdone" id="setdone" value="Set selected  to done" class="button"/>   
                                 -     <input type="submit" name="exporttxt" id="exporttxt" value="Export selected to .txt" class="button"/> 
                                    </center>
                                    
							</fieldset>
						</form>
                            

 

I found that checkbox code sample on some other site and tried to implement it, i don't really know where to go from here, as it's a total mess to me now, any help would be greatly appreciated.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.