Jump to content

Spliting data into colums


freemancomputer

Recommended Posts

I have been working on a way to split my data into 2 columns as a way to make the page shorter and easier to read. I have been able get it to split like this

 

1 2

3 4

5 6

 

But I would rather it go like this, because it would be easier on the eyes.

 

1 4

2 5

3 6

 

This is what I have now, I have no idea if I'm even on the right track.

  <?php
include"scripts/connect.php" ;

mysql_connect('localhost',$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM movies WHERE type LIKE 'tv' ORDER BY title";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();
?>
<table width="70%" align="left">

<?php
$i=0;
while ($i < $num/2)
{

$title=mysql_result($result,$i,"title");

?>
<tr>
<td><a class="nav" href=/show.php?title=<?php echo urlencode($title); ?>><?php echo $title; ?></td>



<?php
while ($i >= $num/2)
{
?>

<td><a class="nav" href=/show.php?title=<?php echo urlencode($title); ?>><?php echo $title; ?></td>
</tr>


<?php
}
$i++;

}

?>
</table>

 

This will show only the first half of the titles.

 

Thanks in advance.

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.