Page 1 of 1

table with php not showing correctly

Posted: Sun Apr 08, 2012 7:12 am
by roial
hello.
the script i made makes the table look awkward, and i've been looking around to find a solution to my problem but couldn't find one that works.
the thing is that after the 4th product/article the table goes messy all around the page.

i am new to php so i went for table layout and this is the solution i prefer since i understand the works of it. i could go with div but would be a bit hard for me.

if you guys have any idea or some good reference i could chekout, please help.

yhanks alot
------------------------------------------------------------------------

Code: Select all


<?php
include_once("admincp/config.inc.php");
$stati=urldecode($_REQUEST['Stati']);
?>

<html>
<head>
<title><?=$title;?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="admin/inc/style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style2 {font-weight: bold; }
.style4 {font-weight: bold; }
.style5 {font-weight: bold}
-->
</style>
</head>
<body>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td align="center" valign="top" class="bg_main"><table width="980" height="438" border="0" cellpadding="0" cellspacing="0" class="base">
        <tr> 
          <td height="10" align="right" valign="top"> 
            <table width="980" border="0" cellpadding="0" cellspacing="0" class="base">
              <tr> 
                <td height="20" valign="top">&nbsp;</td>
              </tr>
              
  <tr> 
    <td align="center" valign="top"><? require_once("header.php"); ?></td>
  </tr>
            </table>          </td>
        </tr>
        
        <tr>
          <td valign="top" align="center" class="a_base"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <th width="213" valign="top" scope="col"><?php require_once("sidebar.php") ?></th>
              <th width="10" scope="col">&nbsp;</th>
              <th valign="top" scope="col"><table width="500" border="0">
                <tr>
                  <td width="140">&nbsp;</td>
                  <td colspan="2">&nbsp;</td>
                </tr>
                <tr>
                  <td align="left" valign="middle"><?php
				$qry_hotel=mysql_query("select * from hotel where statiune='$stati'");
				while ($hotel_rs=mysql_fetch_array($qry_hotel)){
				?>
                      <table width="200" border="0">
                        <tr>
                          <td colspan="2" align="center"><img src="admincp/photos/hotel/<?=$hotel_rs['img1'];?>" width="200" height="150"></td>
                        </tr>
                        <tr>
                          <td width="118" height="28" align="right">&nbsp;</td>
                          <td width="80" align="center" valign="middle" background="imgs/prcbg.jpg" class="sidebar"><span class="style2">
                            <?=$hotel_rs['p_label']." ";?>
                          </span></td>
                        </tr>
                        <tr>
                          <td colspan="2" align="left"><span class="tour"><a href="hotel.php?ID=<?=$hotel_rs['ID'];?>" class="tour">
                           <?=$hotel_rs['nume_hotel'];?>
                          </a></span></td>
                        </tr>
                    </table></td>
                  <td width="145" class="tour"><?php 
				$hotel_rs=mysql_fetch_array($qry_hotel);
				//dont display blank box for picture
				if(!empty ($hotel_rs['nume_hotel'])){
				?>
                      <table width="200" border="0">
                        <tr>
                          <td colspan="2" align="center"><img src="admincp/photos/hotel/<?=$hotel_rs['img1'];?>" width="200" height="150"></td>
                        </tr>
                        <tr>
                          <td width="118" height="28" align="right">&nbsp;</td>
                          <td width="80" align="center" valign="middle" background="imgs/prcbg.jpg" class="sidebar"><span class="style4">
                            <?=$hotel_rs['p_label']."-";?>
                          </span></td>
                        </tr>
                        <tr>
                          <td colspan="2" align="left"><a href="hotel.php?ID=<?=$hotel_rs['ID'];?>" class="tour">
                            <?=$hotel_rs['nume_hotel'];?>
                          </a></td>
                        </tr>
                    </table></td>
                  <td width="193" class="tour"><?php 
				//if closing of third picture box
				}else{ 
				echo ''; }
				$hotel_rs=mysql_fetch_array($qry_hotel);
				//dont display blank box for picture
				if(!empty ($hotel_rs['nume_hotel'])){
				?>
                      <table width="200" border="0">
                        <tr>
                          <td colspan="2" align="center"><img src="admincp/photos/hotel/<?=$hotel_rs['img1'];?>" width="200" height="150"></td>
                        </tr>
                        <tr>
                          <td width="118" height="28" align="right">&nbsp;</td>
                          <td width="80" align="center" valign="middle" background="imgs/prcbg.jpg" class="sidebar"><span class="style5">
                            <?=$hotel_rs['p_label']."...";?>
                          </span></td>
                        </tr>
                        <tr>
                          <td colspan="2" align="left"><a href="hotel.php?ID=<?=$hotel_rs['ID'];?>" class="tour">
                            <?=$hotel_rs['nume_hotel'];?>
                          </a></td>
                        </tr>
                    </table></td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                  <td></td>
                  <td></td>
                </tr>
                <? 
				//if closing of third picture box
				}else{ 
				echo ''; }
				} ?>
              </table></th>
            </tr>
          </table></td>
        </tr>
        <tr>
          <td height="10" align="center" valign="top"><? require_once("bottom.php"); ?></td>
        </tr>
        <tr>
          <td height="10" align="center" valign="top">&nbsp;</td>
        </tr>
        
    </table></td>
  </tr>
</table>


</html>


Re: table with php not showing correctly

Posted: Fri Apr 20, 2012 5:38 pm
by Robert07
Do you have a link for this on a web server so I can see the generated html code and how it is rendered in a browser? It's difficult to help you if we can't see what you are referring to by "table goes messy".

Re: table with php not showing correctly

Posted: Mon Apr 23, 2012 2:04 pm
by x_mutatis_mutandis_x
Your refering to HTML, not PHP. HTML constructs the table, PHP puts the data in it. Can you attach a screenshot of how your table looks on the browser, or a link to your page (if can accessed by public) like Robert suggested

Re: table with php not showing correctly

Posted: Mon Apr 23, 2012 4:29 pm
by litebearer
Not sure if this is it; however, about 17 lines from the bottom you have a </th> which I believe should be a </td>