DanielHardy Posted March 20, 2009 Share Posted March 20, 2009 <?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 Link to comment https://forums.phpfreaks.com/topic/150337-checkboxes-follow-up-could-be-simple-html-fix/ Share on other sites More sharing options...
micah1701 Posted March 20, 2009 Share Posted March 20, 2009 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: } ?> Link to comment https://forums.phpfreaks.com/topic/150337-checkboxes-follow-up-could-be-simple-html-fix/#findComment-789639 Share on other sites More sharing options...
DanielHardy Posted March 20, 2009 Author Share Posted March 20, 2009 Could you possibly put the code back up all uncommented for me? Finding it very hard to follow it. Thanks Link to comment https://forums.phpfreaks.com/topic/150337-checkboxes-follow-up-could-be-simple-html-fix/#findComment-789649 Share on other sites More sharing options...
DanielHardy Posted March 20, 2009 Author Share Posted March 20, 2009 Ok Thats done something. Just added a gap inbetween each <td> Sorry Im just far more faimilar with working with php and other aspects of html. Never really came to terms with how tables work Link to comment https://forums.phpfreaks.com/topic/150337-checkboxes-follow-up-could-be-simple-html-fix/#findComment-789650 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.