Jump to content

Recommended Posts

hello ! i'm fairly new to php and sql so would greatly appreciate if anyone could help me with this.

what i want to do is to get different users to enter a single field say their name through a form and then display it in the following format

 

name 1  name 2    name 3      name 4    name 5

name 6  name 7    name 8      name 9    name 10

name 11  ............so on

 

no. of rows is no limit.

 

here's the code but its not working

 

while ( $row = mysql_fetch_assoc($result) )

{

echo("<tr>"); 

  $ctr=1;

      if($ctr<6)

      {

          echo("<td>"); 

          echo($row["name"]); 

          echo("</td>");

    $ctr++;

     

   

    echo("</tr>");  // end the row

}

your code should be something like the following

 

$ctr=1;
echo "<tr>";   
while ( $row = mysql_fetch_assoc($result) )
{
    if (($ctr%6)==0) {echo "</tr><tr>";}
echo "<td>";   
    echo $row["name"]; 
   echo "</td>";
     $ctr++;
    
}
echo("</tr>");  // end the row

 

hope its helpful

 

 

 

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.