Jump to content

going to a new line in an array


werny

Recommended Posts

Do you mean add a new line (<br />)/paragraph (<p></p>) after ten items have been pulled out from a database? If so then following should do it:

 

$qry = 'YOUR QUERY HERE';
$result = mysql_query($qry);

$i = 0; // Initiate the counter
while($row = mysql_fetch_assoc($result))
{
    // echo your row(s) here


    // check to see if $i is less than 10, if it is increment counter by one, else echo a new line.
    if($i < 10)
        $i++; // increment counter by one
    else
       echo '<br />'; // echo new line if $i is not less than 10;

}

Link to comment
Share on other sites

i'm not really following you. wildteen's code will record EVERY row using the while() loop.

it goes to every row and returns ONLY what you tell it to, using the VALUES. you can then do as he

said with the counter $i as he showed. so if you only want the first 10 values, well you have to see how you

defined them, then have the query retrieve them, make sense?

 

showing us some code would also help.

Link to comment
Share on other sites

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.