realjumper Posted March 26, 2008 Share Posted March 26, 2008 Hi, This is my loop: $num = 1; while($row20 = mysql_fetch_array( $result20 )) { // Print out the contents of each row into a table echo "<tr>"; echo "<td><input type=\"checkbox\" name=\"$num\" value=\"$row20[email]\" onClick=\"forward.disabled=true;emiko.disabled=true;\"></td>"; $full_name = ucwords(strtolower($row20[full_name])); echo "<td>$full_name</td>"; echo "</tr>"; $num++; } The above gives a list down the page of results like this, with each name in it's own table cell...and row: John Smith Ian Bell George Brown Jane Doe How can I make it display like this, so that I have two users per table row, each in their own table cell? John Smith Ian Bell George Brown Jane Doe Thanks :-) Link to comment https://forums.phpfreaks.com/topic/97904-looping-results-layout-help/ Share on other sites More sharing options...
teng84 Posted March 26, 2008 Share Posted March 26, 2008 try $num = 1; while($row20 = mysql_fetch_array( $result20 )) { if($num % 2!=0){ echo "<tr>"; echo "<td><input type=\"checkbox\" name=\"$num\" value=\"$row20[email]\" onClick=\"forward.disabled=true;emiko.disabled=true;\"></td>"; }else{ $full_name = ucwords(strtolower($row20[full_name])); echo "<td>$full_name</td>"; echo "</tr>"; } $num++; } Link to comment https://forums.phpfreaks.com/topic/97904-looping-results-layout-help/#findComment-500907 Share on other sites More sharing options...
realjumper Posted March 26, 2008 Author Share Posted March 26, 2008 Thanks...that's closer but what is is giving is the same single column list of only half the users! It is listing users 2, 4, 6, 8 etc etc like this: Ian Bell Jane Doe Link to comment https://forums.phpfreaks.com/topic/97904-looping-results-layout-help/#findComment-500908 Share on other sites More sharing options...
teng84 Posted March 26, 2008 Share Posted March 26, 2008 $num = 1; while($row20 = mysql_fetch_array( $result20 )) { $full_name = ucwords(strtolower($row20[full_name])); if($num % 2!=0){ echo "<tr>"; echo "<td>$full_name</td>"; }else{ echo "<td>$full_name</td>"; echo "</tr>"; } $num++; } that should give to columns but i not sure what exactly you want! Link to comment https://forums.phpfreaks.com/topic/97904-looping-results-layout-help/#findComment-500914 Share on other sites More sharing options...
realjumper Posted March 26, 2008 Author Share Posted March 26, 2008 Thank you teng84.......here is what I was after, which is soooo close to your solution. I appreciate your help....now I will figure out how it works :-) $num = 1; while($row20 = mysql_fetch_array( $result20 )) { $full_name = ucwords(strtolower($row20[full_name])); if($num % 2!=0){ echo "<tr>"; echo "<td><input type=\"checkbox\" name=\"$num\" value=\"$row20[email]\" onClick=\"forward.disabled=true;emiko.disabled=true;\"></td>"; echo "<td>$full_name</td>"; }else{ echo "<td><input type=\"checkbox\" name=\"$num\" value=\"$row20[email]\" onClick=\"forward.disabled=true;emiko.disabled=true;\"></td>"; echo "<td>$full_name</td>"; echo "</tr>"; } $num++; } [code] [/code] Link to comment https://forums.phpfreaks.com/topic/97904-looping-results-layout-help/#findComment-500924 Share on other sites More sharing options...
TRI0N Posted March 26, 2008 Share Posted March 26, 2008 The easiest way to deal with this since your HTML layout has " " in it is to place the echo in ' ' (No Shift). Example: echo '<td><input type="checkbox" name="'.$num.'" value="'.$row[email].'" onClick="forward.disabled=true;emiko.disabled=true;"></td>' ; No need for back slashes anymore to signify a quote character inside quoted code. Pointless and twice the work.. Link to comment https://forums.phpfreaks.com/topic/97904-looping-results-layout-help/#findComment-500933 Share on other sites More sharing options...
realjumper Posted March 26, 2008 Author Share Posted March 26, 2008 Yes TRION, you're quite correct.....I was brought up on backslashes and it's a hard habit to break!!! Link to comment https://forums.phpfreaks.com/topic/97904-looping-results-layout-help/#findComment-500940 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.