Jump to content

Checkboxes follow up (could be simple html fix)


DanielHardy

Recommended Posts





<?php
include "page.class";

$Sample = new Page;

$Content = "
<HTML>
<BODY>

</BODY>
</HTML>";

$Sample->Title = "Please Book Seats!";
$Sample->Keywords = "PHP, Classes";
$Sample->SetContent( $Content );

$Sample->Display( );

?>       

<?php  
    include("login.php");
    $updated = FALSE;  
    if(count($_POST) > 0){  
        $admin = $_POST['admin'];  
        array_map('intval',$admin);  
        $admin = implode(',',$admin);  
       
        mysql_query("UPDATE seats SET admin=1 WHERE id IN ($admin)") or trigger_error(mysql_error(),E_USER_ERROR);  
       $updated=TRUE;  
   }  
   ?>  

   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">  
   <html xmlns="http://www.w3.org/1999/xhtml">  
   <head>  
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />  
   <title></title>  
   </head>  
   <body>  
   <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">  
   <?php  
    
   ?>  
   <table>  
   <tr>  
   <th></th>  
   <th>Seat Booking System</th>  
   </tr>  
   <?php  
$booked = "Seat Booked";
    
   $sql = "SELECT id,username,admin,rowId,columnId FROM seats ORDER by id ASC";  

   $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR);  
   while(list($id,$username,$admin,$columnId,$rowId,)=mysql_fetch_row($result)){

if($admin==1){ 
        
    
       echo '<tr bgcolor="red" ><td><font color="white">'.$columnId.''.$rowId.'</td><td>'.$booked.'</td></tr>'."\n";    
   
   }

if($admin==0){  
       $checked = ($admin==1) ? 'checked="checked"' : ''; 
    
      echo '<tr bgcolor="green" ><td><font color="white">'.$columnId.''.$rowId.'</td><td><input type="checkbox" name="admin[]" value="'.$id.'"  /></td></tr>'."\n";  
   
   }
}


   ?>  

 

 

The following code simply updates a status row in my database andchanges the design of the checkbox. View it working at: http://mi-linux.wlv.ac.uk/~0607197/test.php (login with:username :  jesus, password  :1)

 

As you will notice the layout isntthe best ( to say the least)

 

Im sure there is an easy fix to get say ten <td>'s on a line and then automatiall start a new line.

 

Suggestions please.

 

Thanks

 

Dan

you could add a loop within your loop.

 

you could add a loop within your loop.

 

<?php $i=1;

// star your current loop: while(......){

if($i=1){ echo "<tr>"; }

// the rest of your code here

if($i=10){ echo "</tr>";  $i=1;  } else { $i++; }

// end your loop: } 
?>

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.