Results 1 to 9 of 9

Thread: Little bit more help needed pleeeease! Formatting a table containing mysql data

  1. #1
    Kirstie Allsopp Theo's Avatar
    Join Date
    Jul 2003
    Location
    Sunny Bolton
    Posts
    2,777
    Thanks
    17
    Thanked
    23 times in 20 posts
    • Theo's system
      • Motherboard:
      • Asus P5B Wifi deluxe
      • CPU:
      • E6600 @ 3150Mhz
      • Memory:
      • 2x2GB OCZ 6400
      • Storage:
      • 1x80GB Maxtor
      • Graphics card(s):
      • 640MB 8800GT
      • Monitor(s):
      • ASUS M221u
      • Internet:
      • Be Value

    Little bit more help needed pleeeease! Formatting a table containing mysql data

    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..

  2. #2
    HEXUS.net Webmaster
    Join Date
    Jul 2003
    Location
    UK
    Posts
    3,108
    Thanks
    1
    Thanked
    0 times in 0 posts
    Code:
    echo "<br><br><table border=0 table width=500>";
    no need for the second table

    More importantly if you view the source of your page you can see it's full of badly formed HTML with tables nested inside divs and all sorts. Remove all the tables from within the divs with id "bd" and see if it improves

  3. #3
    HEXUS.net Webmaster
    Join Date
    Jul 2003
    Location
    UK
    Posts
    3,108
    Thanks
    1
    Thanked
    0 times in 0 posts
    In fact, you haven't even defined a style for "bd" so what's the point in using it ? Take the source from your page and rewrite it as a static page of HTML which is properly formed and then work out how to get to that using PHP.

  4. #4
    Kirstie Allsopp Theo's Avatar
    Join Date
    Jul 2003
    Location
    Sunny Bolton
    Posts
    2,777
    Thanks
    17
    Thanked
    23 times in 20 posts
    • Theo's system
      • Motherboard:
      • Asus P5B Wifi deluxe
      • CPU:
      • E6600 @ 3150Mhz
      • Memory:
      • 2x2GB OCZ 6400
      • Storage:
      • 1x80GB Maxtor
      • Graphics card(s):
      • 640MB 8800GT
      • Monitor(s):
      • ASUS M221u
      • Internet:
      • Be Value
    The website has changed since I originally posted, sorry for the hassle. You're coming across a little harsh, there, I apologise if I'm new to this, but I haven't received any tutelage in anything more than a html form/php script. So making a site like that with nothing to go from was a bit hard.

    Sorry if I've read your posts wrong, no offense intended - just the way they came across.

    Thanks for the tips, anyway.

  5. #5
    Kirstie Allsopp Theo's Avatar
    Join Date
    Jul 2003
    Location
    Sunny Bolton
    Posts
    2,777
    Thanks
    17
    Thanked
    23 times in 20 posts
    • Theo's system
      • Motherboard:
      • Asus P5B Wifi deluxe
      • CPU:
      • E6600 @ 3150Mhz
      • Memory:
      • 2x2GB OCZ 6400
      • Storage:
      • 1x80GB Maxtor
      • Graphics card(s):
      • 640MB 8800GT
      • Monitor(s):
      • ASUS M221u
      • Internet:
      • Be Value
    Bloody hell, I sound like a right moron. Apologies are due. I haven't slept for a few days, so I'm a bit nowty.

    Thanks for taking the time to read through everything. You may not think so after reading my last post, but it's much appreciated. Deadline day is today, so it's a little late to go through everything and do what you said, but I'll keep it in mind for next time. Like I said, it's my first attempt, so it's bound to be ~(very) sloppy. It doesn't particularly matter for this assignment though, luckily.

    Thanks again.
    Last edited by Theo; 21-05-2004 at 08:26 AM.

  6. #6
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    Theo you have your home address and phone number on your website? o_O

    Blues eh? Goooood stuff

  7. #7
    Kirstie Allsopp Theo's Avatar
    Join Date
    Jul 2003
    Location
    Sunny Bolton
    Posts
    2,777
    Thanks
    17
    Thanked
    23 times in 20 posts
    • Theo's system
      • Motherboard:
      • Asus P5B Wifi deluxe
      • CPU:
      • E6600 @ 3150Mhz
      • Memory:
      • 2x2GB OCZ 6400
      • Storage:
      • 1x80GB Maxtor
      • Graphics card(s):
      • 640MB 8800GT
      • Monitor(s):
      • ASUS M221u
      • Internet:
      • Be Value
    Feel free to send me stuff I never get things in the post, anyway.

    Thanks for the wake-up call, though... I think I'll say they're available on request, or something.

  8. #8
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    Everything but address and telephone number is fine on a website. If it's a company addresses and telephone numbers are allowed but for a personal one that's bad news.

  9. #9
    Kirstie Allsopp Theo's Avatar
    Join Date
    Jul 2003
    Location
    Sunny Bolton
    Posts
    2,777
    Thanks
    17
    Thanked
    23 times in 20 posts
    • Theo's system
      • Motherboard:
      • Asus P5B Wifi deluxe
      • CPU:
      • E6600 @ 3150Mhz
      • Memory:
      • 2x2GB OCZ 6400
      • Storage:
      • 1x80GB Maxtor
      • Graphics card(s):
      • 640MB 8800GT
      • Monitor(s):
      • ASUS M221u
      • Internet:
      • Be Value
    Did anyone ring me today? Heh... the missus picked the phone up to a "posh sounding bloke" who asked if I'd gone into college yet, but wouldn't disclose his name/number. Was a with-held call, too! Just wondering whether someone saw my CV before I managed to edit it, and decided to spring one on me, or something

    I now see why I should remove home numbers/addresses from the site - thanks Kezzer

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Radeon 8500 linux driver install problems
    By Dorza in forum Software
    Replies: 0
    Last Post: 22-09-2003, 12:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •