Jump to content

Recommended Posts

I have 50 states and I want my loop display 5 columns.

 

right now my loop displays all 50 states in one column. I setup a table but I don`t know how to echo </td></tr><tr><td> every ten states in the loop.

 

I am trying to get it to do

 

1                                                continue

2                                                7

3                                                8

4                                                9

5                                                etc.

6 break echo </td></tr><tr><td>

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/161209-need-help-with-loop-rows-and-columns/
Share on other sites

Can you post the relevant code?  You said you want to display every 10 rows, yet your example does not exemplify this.

 

You have to use the modulus (%) operator in your while loop to check if the row count is divisible by 10 (every 10 rows).

 

 

NOTE - Is there a reason you posted in the Framworks section?  If not, I can move this to the more popular, "PHP Help" for additional help.

Sorry about the example it would have been too much typing.  You can move it to help.

 

$ctryfrom = "SELECT DISTINCT country FROM table";
$ctry = mysql_query($ctryfrom);

while($row = mysql_fetch_assoc($ctry)){
$countrynames = $row['country'];

echo '<table><tr><td>';
echo "$countrynames";

//I want to echo </td></tr><tr><td> to add another column in the table. How can I set it to echo
            }


This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.