psychowolvesbane Posted January 5, 2008 Share Posted January 5, 2008 Okay I got this code that places each record from the table Colours (1 field called AvailableColours) and palces those records in an array. What I have below displays a table with each odd row with an image with the same name as the array value and a row of check buttons underneath each one that have matching names. However this ends up displaying every record in a single line as so: http://i110.photobucket.com/albums/n82/psychofox19/example1.jpg But I want it to look like this: http://i110.photobucket.com/albums/n82/psychofox19/example2.jpg (Example done manually) Can anyone help with the coding? <?php //Establish a connection to the Database $conn = mysql_connect('$host','$username','$password'); //Select the MySQL database $db = mysql_select_db('$dbname', $conn); //Issue SQL SELECT Statement $sql = "SELECT AvailableColours FROM Colours ORDER BY AvailableColours"; //Execute the SQL Statement and create a recordset $rs = mysql_query($sql, $conn) or die(mysql_error()); $NumberOfColours = mysql_num_rows($rs); while($row = mysql_fetch_array($rs)) { $Colour[] = $row[AvailableColours]; } $X=0; ?> <fieldset style="padding: 2"> <legend>Available Colours</legend> <table border="1" id="Colours"> <tr> <?php if($NumberOfColours<18) { while($X<17) { echo"<td><img src='/images/colours/$Colour[$X].gif' width='25' height='25' alt='$Colour[$X]'></td>"; $X=$X+1; } $X=0; ?> </tr> <tr> <?php while($X<17) { echo"<td><input type='checkbox' name='$Colour[$X]' value='ON'></td>"; $X=$X+1; } } else { while($X<$NumberOfColours) { echo"<td><img src='/images/colours/$Colour[$X].gif' width='25' height='25' alt='$Colour[$X]'></td>"; $X=$X+1; } $X=0; ?> </tr> <tr> <?php while($X<$NumberOfColours) { echo"<td><input type='checkbox' name='$Colour[$X]' value='ON'></td>"; $X=$X+1; } } ?> </tr> <table> </legend> </fieldset> Quote Link to comment https://forums.phpfreaks.com/topic/84670-solved-form-table-help/ Share on other sites More sharing options...
pocobueno1388 Posted January 5, 2008 Share Posted January 5, 2008 This is such a common question, it has it's own thread dedicated to it. http://www.phpfreaks.com/forums/index.php/topic,95426.0.html Quote Link to comment https://forums.phpfreaks.com/topic/84670-solved-form-table-help/#findComment-431482 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.