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;

}

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.

Archived

This topic is now archived and is closed to further replies.

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