davieboy Posted April 1, 2007 Share Posted April 1, 2007 in trying to create a seat plan where im able to have a list of rows/seats like ABC DEF 1 === === 2 === === 3 === === 4 === === ... and where when clicked, each seat will have an id number How do i do this David Quote Link to comment https://forums.phpfreaks.com/topic/45156-seat-plan/ Share on other sites More sharing options...
Full-Demon Posted April 1, 2007 Share Posted April 1, 2007 I dont understand what you're trying to make :S, can you explain a little more? Full-Demon Quote Link to comment https://forums.phpfreaks.com/topic/45156-seat-plan/#findComment-219217 Share on other sites More sharing options...
tippy_102 Posted April 1, 2007 Share Posted April 1, 2007 Loop through the rows (1-whatever), then inside that, loop through the seats (A-F). Combine the row and seat to give you an ID of something like $1A....is that what you want do do? Quote Link to comment https://forums.phpfreaks.com/topic/45156-seat-plan/#findComment-219267 Share on other sites More sharing options...
Daniel0 Posted April 1, 2007 Share Posted April 1, 2007 May not be particularly efficient, but here is an example: <?php $num_seats = 10; $arr = array('A','B','C','D','E','F'); echo <<<EOF <h1>Select seats</h1> <table> <tr> <th> </th> EOF; foreach($arr as $arr2) { echo <<<EOF <th>{$arr2}</th> EOF; } echo <<<EOF </tr> EOF; for($i=1; $i<=$num_seats; $i++) { echo <<<EOF <tr> <th>{$i}</th> EOF; foreach($arr as $arr2) { echo <<<EOF <td><input type="checkbox" name="seat[{$i}][{$arr2}]" /></td> EOF; } echo <<<EOF </tr> EOF; } echo <<<EOF </table> EOF; ?> Generated code: <h1>Select seats</h1> <table> <tr> <th> </th> <th>A</th> <th>B</th> <th>C</th> <th>D</th> <th>E</th> <th>F</th> </tr> <tr> <th>1</th> <td><input type="checkbox" name="seat[1][A]" /></td> <td><input type="checkbox" name="seat[1][b]" /></td> <td><input type="checkbox" name="seat[1][C]" /></td> <td><input type="checkbox" name="seat[1][D]" /></td> <td><input type="checkbox" name="seat[1][E]" /></td> <td><input type="checkbox" name="seat[1][F]" /></td> </tr> <tr> <th>2</th> <td><input type="checkbox" name="seat[2][A]" /></td> <td><input type="checkbox" name="seat[2][b]" /></td> <td><input type="checkbox" name="seat[2][C]" /></td> <td><input type="checkbox" name="seat[2][D]" /></td> <td><input type="checkbox" name="seat[2][E]" /></td> <td><input type="checkbox" name="seat[2][F]" /></td> </tr> <tr> <th>3</th> <td><input type="checkbox" name="seat[3][A]" /></td> <td><input type="checkbox" name="seat[3][b]" /></td> <td><input type="checkbox" name="seat[3][C]" /></td> <td><input type="checkbox" name="seat[3][D]" /></td> <td><input type="checkbox" name="seat[3][E]" /></td> <td><input type="checkbox" name="seat[3][F]" /></td> </tr> <tr> <th>4</th> <td><input type="checkbox" name="seat[4][A]" /></td> <td><input type="checkbox" name="seat[4][b]" /></td> <td><input type="checkbox" name="seat[4][C]" /></td> <td><input type="checkbox" name="seat[4][D]" /></td> <td><input type="checkbox" name="seat[4][E]" /></td> <td><input type="checkbox" name="seat[4][F]" /></td> </tr> <tr> <th>5</th> <td><input type="checkbox" name="seat[5][A]" /></td> <td><input type="checkbox" name="seat[5][b]" /></td> <td><input type="checkbox" name="seat[5][C]" /></td> <td><input type="checkbox" name="seat[5][D]" /></td> <td><input type="checkbox" name="seat[5][E]" /></td> <td><input type="checkbox" name="seat[5][F]" /></td> </tr> <tr> <th>6</th> <td><input type="checkbox" name="seat[6][A]" /></td> <td><input type="checkbox" name="seat[6][b]" /></td> <td><input type="checkbox" name="seat[6][C]" /></td> <td><input type="checkbox" name="seat[6][D]" /></td> <td><input type="checkbox" name="seat[6][E]" /></td> <td><input type="checkbox" name="seat[6][F]" /></td> </tr> <tr> <th>7</th> <td><input type="checkbox" name="seat[7][A]" /></td> <td><input type="checkbox" name="seat[7][b]" /></td> <td><input type="checkbox" name="seat[7][C]" /></td> <td><input type="checkbox" name="seat[7][D]" /></td> <td><input type="checkbox" name="seat[7][E]" /></td> <td><input type="checkbox" name="seat[7][F]" /></td> </tr> <tr> <th>8</th> <td><input type="checkbox" name="seat[8][A]" /></td> <td><input type="checkbox" name="seat[8][b]" /></td> <td><input type="checkbox" name="seat[8][C]" /></td> <td><input type="checkbox" name="seat[8][D]" /></td> <td><input type="checkbox" name="seat[8][E]" /></td> <td><input type="checkbox" name="seat[8][F]" /></td> </tr> <tr> <th>9</th> <td><input type="checkbox" name="seat[9][A]" /></td> <td><input type="checkbox" name="seat[9][b]" /></td> <td><input type="checkbox" name="seat[9][C]" /></td> <td><input type="checkbox" name="seat[9][D]" /></td> <td><input type="checkbox" name="seat[9][E]" /></td> <td><input type="checkbox" name="seat[9][F]" /></td> </tr> <tr> <th>10</th> <td><input type="checkbox" name="seat[10][A]" /></td> <td><input type="checkbox" name="seat[10][b]" /></td> <td><input type="checkbox" name="seat[10][C]" /></td> <td><input type="checkbox" name="seat[10][D]" /></td> <td><input type="checkbox" name="seat[10][E]" /></td> <td><input type="checkbox" name="seat[10][F]" /></td> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/45156-seat-plan/#findComment-219280 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.