Page 1 of 1

dont know why my table's in the wrong place

Posted: Mon Aug 25, 2008 9:51 pm
by cali_dotcom
when i run this script the table generated does not appear where it is supposed to instead it appears way
to the right of the window, you would actually have to scroll to the right, and i just dont know why.
here the code>>

Code: Select all

 
<?php
$mysql = mysql_connect("localhost", "root", "") or die("couldn't connect to server");
    $db = mysql_select_db("jobpage", $mysql) or die("couldn't connect to database");
 
//build query for healthcare jobs where cat_id = 17
 
$cat_id = 17;
 
$query = "select job_id, emp_id, job_title, job_desc, job_pay, post_date from jobs where cat_id = $cat_id";
$res = mysql_query($query) or die ("couldn't selcet from database");
 
 
//if there are at least one records in $res,
if (mysql_num_rows($res) >= 1){
    
    $display .=" <table width='100%' border = '1'><tr><td>Job Title</td><td>Job Description</td><td>Job Pay</td><td>Post Date</td></tr>";
    
    while ($row = mysql_fetch_assoc($res)){
        $job_id = $row['job_id'];
        $emp_id = $row['emp_id'];
        $job_title = $row['job_title'];
        $job_desc = $row['job_desc'];
        $job_pay = $row['job_pay'];
        $job_loc = $row['job_loc'];
    
        $post_date = $row['post_date'];
        
        $display .=" <tr><td><a  href='".$_SERVER["PHP_SELF"]."?job_id=".$job_id."'>  '".$job_title."'</a></td><td>'".$job_desc."'</td><td>'".$job_pay."'</td><td>'".$post_date."'</td>";
    
        
    }
    $display .="</tr></table>  ";
    
} else{
    $display .="Sorry, there are currently no jobs in this category";
}
 
 
mysql_close($mysql);
?>
<html>
<head><title>Healthcare Jobs</title>
<link href='style.css' type='text/css' rel='stylesheet' />
</head>
<body>
 
<div id ='header'>
    <h1 style="color: #FBD539;"><a href="jobpage.php"> JobPage</a></h1>
    <h3>The world's most specialized Job website</h3>
    </div>
    
    <div id = 'nav_bar'>
    <div id="navcontainer">
    <ul id='navlist'>
      <li><a href='jobpage.php'>Home</a></li>
      <li><a href='signup.php'>Sign Up</a></li>
      <li><a href='signin.html'>Employers</a></li>
 
      <li><a href='#'>Item four</a></li>
      </ul>
    </div>
    </div>
<div id="page_wrapper">
<div id="content_wrapper">
 
<div >
<?php echo $display; ?>
</div>
 
</div>
</div>
 
</body></html>
 
and here are the css codes
 
 
 
#content_wrapper {
  margin-top:0;
  margin-bottom:10px;
  margin-left:01px;
  margin-right:10px;      
  border:0px dashed #FFFFFF;  
}
 
#page_wrapper {
  margin-left: auto; 
  margin-right: auto;
  width: 960px;
  text-align: left;
  background: #FFFFFF url('../img/content_bg.gif') top left repeat-y;
}
 
#header {
  height: 140px;
  background: #8B4500;
  clear: both;
}
 
#header h1 {
  padding-top:50px; padding-left:15px;
  margin:0px;
  font-family: verdana;
  font-size: 44px;
  color: #ffffff;
  line-height:46px;
  letter-spacing:-1px;
}
 
#header h3 {
  margin:0px;
  padding-left:15px;
  font-family: verdana;
  font-size: 12px;
  color: #D5D0B0;
  line-height:22px;
}
 
#nav_bar {
  margin:0px;
  padding:0px;
  border:0px dashed #cccccc;
  height:31px;
  clear:both;
  
}
 
 

Re: dont know why my table's in the wrong place

Posted: Tue Aug 26, 2008 12:16 am
by it2051229
hmm... debug it... i think its with the css code... try removing the wrappers..

Re: dont know why my table's in the wrong place

Posted: Wed Aug 27, 2008 1:03 am
by califdon
You are sending the table and its data to the browser before you even send the opening <html> tag. I'm surprised that it displays on the page at all. Move the entire php section down into the body of your page.