Hello, I'm currently in the middle of another assignment. This time it's a self-appraising portfolio site. As part of it, I am supposed to create a php script of some sort.. so I decided to code several. I've had no problems with the processing parts of the scripts, however, I do have one problem.
whenever I try to display results from a MySQL db in either a table, or a css fixed width <div> comment, the data still ends up being wider than it should be.
The query script is used as an include in the main index page here:
www.iamtheking.net/html/index.php
get.php:
Code:
<?php
$connection = mysql_connect("localhost","","") or die ("Couldn't connect to database server.");
$db = mysql_select_db("" , $connection) or die("Couldn't select database.");
$sql = 'SELECT `id`, `title` , `text`';
$sql .= 'FROM `iamtheking` ';
$sql .= 'ORDER by id DESC LIMIT 0,5';
$sql_result = mysql_query($sql,$connection) or die("Couldn't execute query");
echo "<br><br><table border=0 table width=500>";
while ($myrow = mysql_fetch_array($sql_result)) {
$id = $myrow["id"];
$title = $myrow["title"];
$text = $myrow["text"];
echo "
<tr>
<th><strong>$title</strong></th>
<tr>
<td>
<h1>$text</h1>
</td>
</tr>
";
}
echo "</TABLE>";
mysql_free_result($sql_result);
mysql_close($connection);
?>
index.php:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>IamTHEKING.net</title>
<style type="text/css">
body {
font-family: arial, helvetica, serif;
}
ul { padding: 0;
margin: 0;
list-style: none;
}
li {
float: left;
position: relative;
width: 10em;
background-color:#66CCFF;
}
li ul {
display: none;
position: absolute;
top: 100%;
left: 0;
font-weight: normal;
padding: 0.5em 0 1em 0;
border-right: solid 1px #7d6340;
}
li>ul {
top: auto;
left: auto;
}
li:hover ul, li.over ul {
display: block;
}
#content {
clear: left;
}
</style>
<script type="text/javascript">
startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
}
node.onmouseout=function() {
this.className=this.className.replace(" over", "");
}
}
}
}
}
window.onload=startList;
</script>
</head>
<body>
<div id="content">
<ul id="nav">
<li><a href="?id=home">Home</a></li>
<li>Profile
<ul>
<li><a href="?id=cv">Curriculum Vitae</a></li>
<li><a href="?id=about">About Me</a></li>
</ul>
</li>
<li>Interact
<ul>
<li><a href="?id=email">Email Me</a></li>
<li><a href="">Music</a></li>
</ul>
</li>
</ul>
</div>
<?php
switch($id) {
default:
include('get.php');
break; case "email":
include('email.php');
break; case "cv":
include('cv.php');
break; case "about":
include('about.php');
break; case "home";
include('get.php');
}
?>
</body>
</html>
I've done this before, as can be seen here www.iamtheking.net/psychotoxic/ and I didn't have any problems at all. Any help would be greatly appreciated, as I'm quite stumped/frustrated with it at the moment..