PHP and Tables... please help

Hi everyone… I have a thumbnail page that is putting out tables that are skewed and I am not able to use CSS properly because of that. Is there anyways I can change the PHP output? This is my code… I think the highlighted area is responsible for my tables? But it is mismatching the <tr> and <td> tags…

I really want it to show a structured table… like


 // Thumbnail Listing

else if( $cid && empty( $pid ) )


  $number_of_thumbs_in_row = 4;

// If current page number, use it 

  // if not, set one! 


      $page = 1; 

  } else { 

      $page = $_GET['page']; 


// Define the number of results per page 

  $max_results = 400; 

// Figure out the limit for the query based 

// on the current page number. 

  $from = (($page * $max_results) - $max_results); 

  $result = mysql_query("
        , photo_caption
        , photo_filename 
        , photo_category
        $from, $max_results

  $nr = mysql_num_rows( $result );

  if( empty( $nr ) )


   $result_final = "\	<tr><td>No Photos found</td></tr>\




   while( $row = mysql_fetch_array( $result ) )


    $result_array[]= "<a href='viewgallery.php?cid=$cid&pid=".$row[0]."'><img 

    src='".$images_dir."/tb_".$row[2]."' border='0' alt='".$row[1]."' class='img'/></a>";


    $result = mysql_query( "SELECT category_name FROM gallery_category WHERE category_id='".addslashes($cid)."'" ); 

    list($category_name) = mysql_fetch_array( $result ); 

    mysql_free_result( $result );     

    $result_final = "<tr>\
\	<td> 

                        <span class='navlinks'><a href=viewgallery.php>Albums</a></span><font color=#ff0000> >&gt </font>

                        <span class='navlinks'><a href=viewgallery.php?cid=$cid>$category_name</a></span><br><br/><br/><br/></td>\

   foreach($result_array as $thumbnail_link)


    if($counter == $number_of_thumbs_in_row)


     $counter = 1;

     [b][size=24pt][size=18pt][b]$result_final .= "\




   [b][size=18pt] $result_final .= "\	<td>".$thumbnail_link."</td>\




And my HTML output shows the tables like this…


<table width='100%' border='0' align='center' style='width: 80%;'>


                        <span class='navlinks'><a href=viewgallery.php>Albums</a></span><font color=#ff0000> >&gt </font>

                        <span class='navlinks'><a href=viewgallery.php?cid=1>Abstract</a></span><br><br/><br/><br/></td>
    <td><a href='viewgallery.php?cid=1&pid=240'><img 

    src='photos/tb_240.jpg' border='0' alt='End Of Day' class='img'/></a></td>
    <td><a href='viewgallery.php?cid=1&pid=239'><img 

    src='photos/tb_239.jpg' border='0' alt='A Photographer's Dream' class='img'/></a></td>

    <td><a href='viewgallery.php?cid=1&pid=238'><img 

    src='photos/tb_238.jpg' border='0' alt='Heaven's View' class='img'/></a></td>
    <td><a href='viewgallery.php?cid=1&pid=237'><img 

    src='photos/tb_237.jpg' border='0' alt='Colorful World ' class='img'/></a></td>

    <td><a href='viewgallery.php?cid=1&pid=241'><img 

    src='photos/tb_241.jpg' border='0' alt='' class='img'/></a></td>
    <td><a href='viewgallery.php?cid=1&pid=242'><img 

    src='photos/tb_242.jpg' border='0' alt='' class='img'/></a></td>
    <td><a href='viewgallery.php?cid=1&pid=243'><img 

    src='photos/tb_243.jpg' border='0' alt='' class='img'/></a></td>
    <td><a href='viewgallery.php?cid=1&pid=244'><img 

    src='photos/tb_244.jpg' border='0' alt='' class='img'/></a></td>


    <td><a href='viewgallery.php?cid=1&pid=245'><img 

    src='photos/tb_245.jpg' border='0' alt='' class='img'/></a></td>
    <td><a href='viewgallery.php?cid=1&pid=246'><img 

    src='photos/tb_246.jpg' border='0' alt='' class='img'/></a></td>
    <td><a href='viewgallery.php?cid=1&pid=247'><img 

    src='photos/tb_247.jpg' border='0' alt='' class='img'/></a></td>
    <td><a href='viewgallery.php?cid=1&pid=248'><img 

    src='photos/tb_248.jpg' border='0' alt='' class='img'/></a></td>

    <td><a href='viewgallery.php?cid=1&pid=249'><img 

    src='photos/tb_249.jpg' border='0' alt='' class='img'/></a></td>
    <td><a href='viewgallery.php?cid=1&pid=250'><img 

    src='photos/tb_250.jpg' border='0' alt='' class='img'/></a></td>
    <td><a href='viewgallery.php?cid=1&pid=251'><img 

    src='photos/tb_251.jpg' border='0' alt='' class='img'/></a></td>

    <td><a href='viewgallery.php?cid=1&pid=252'><img 

    src='photos/tb_252.jpg' border='0' alt='' class='img'/></a></td>

    <td><a href='viewgallery.php?cid=1&pid=253'><img 

    src='photos/tb_253.jpg' border='0' alt='' class='img'/></a></td>
    <td><a href='viewgallery.php?cid=1&pid=254'><img 

    src='photos/tb_254.jpg' border='0' alt='' class='img'/></a></td>
    <td><a href='viewgallery.php?cid=1&pid=255'><img 

    src='photos/tb_255.jpg' border='0' alt='' class='img'/></a></td>




Please help…

Highlighted area displayed wrong for some reason…and the added extra infor to the codes… :slight_smile: here is the corrected version…

This is solved now…thank you all… :slight_smile: