Displaying MYSQL Data into Tables - Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Webmaster Tech > Databases - MySQL, SQL, Oracle, Access and others

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 07-17-2011, 04:53 PM   #1 (permalink)
Junior Member
 
Join Date: Jul 2011
Posts: 2
Default Displaying MYSQL Data into Tables

Hello,
I currently have a problem with a MySQL script, that'll output data to my page. Here is the script that I have:

This page is called: get_email.php (Just for testing purposes)
Code:
<?php
include 'config.php';
?>  
<?php
mysql_connect ("localhost", $username, $password);
@mysql_select_db($database) or die("Unable to select database");
$user_result = mysql_query("SELECT username FROM users");
$email_result = mysql_query("SELECT email FROM users");
print "<table width="100%">";
print "<thead>";
print "<tr>";
print "<th>Username</th>";
print "<th>Email Address</th>";
print "<th>Actions</th>";
print "<th><input name="" type="checkbox" value="" id="checkboxall" /></th>";
print "</tr>";
print "</thead>";
print "<tbody>";
while ($get_email = mysql_fetch_row($user_result)){
while ($get_user = mysql_fetch_row($email_result)){ 
print "<tr>";
foreach ($user_result as $usercred)  
foreach ($email_result as $emailcred)  
print "</td>$user_result</td>";
print "</td>$email_result</td>";
print "</tr>";
}
print "</tbody>";
?>
This page is called: index.php
Code:
<? 
include '../header.php';
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PS3Panda &bull; Housekeeping &bull; Home</title>
<link href="styles/layout.css" rel="stylesheet" type="text/css" />
<link href="styles/wysiwyg.css" rel="stylesheet" type="text/css" />
<!-- Theme Start -->
<link href="themes/blue/styles.css" rel="stylesheet" type="text/css" />
<!-- Theme End -->

</head>


<body id="homepage">
	<div id="header">
    	<a href="" title=""><img SRC="img/cp_logo.png" alt="Control Panel" class="logo" /></a>
    	<div id="searcharea">
            <p class="left smltxt"><a href="#" title="">Advanced</a></p>
            <input type="text" class="searchbox" value="Search control panel..." onclick="if (this.value =='Search-2520control-2520panel..-2E'){this.value=''}"/>
            <input type="submit" value="Search" class="searchbtn" />
        </div>
    </div>
        
    <!-- Top Breadcrumb Start -->
    <div id="breadcrumb">
    	<ul>	
        	<li><img SRC="img/icons/icon_breadcrumb.png" alt="Location" /></li>
        	<li><strong>Location:</strong></li>
            <li><a href="#" title="">Control Panel</a></li>
            <li>/</li>
            <li class="current">Manage Users</li>
        </ul>
    </div>
    <!-- Top Breadcrumb End -->
     
    <!-- Right Side/Main Content Start -->
    <div id="rightside">
    
    	<!-- Status Bar Start --><!-- Status Bar End -->
        
         <!-- Red Status Bar Start --><!-- Red Status Bar End -->
        
        <!-- Green Status Bar Start --><!-- Green Status Bar End -->
        
        <!-- Blue Status Bar Start --><!-- Blue Status Bar End -->   
    
        <!-- Content Box Start -->
      <div class="contentcontainer">
            <div class="headings alt">
                <h2>Create New User</h2>
            </div>
            <div class="contentbox">
            	<table><form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
                	<tr>
                    	<td width="150"><strong>Current Password:</strong></td>
                        <td width="500"><label for="user">
                          <input name="user" type="text" class="inputbox" id="user" />
                        </label></td>
                    </tr>
                    <tr>
                    	<td><strong>New Password:</strong></td>
                        <td><label for="pass">
                          <input name="pass" type="password" class="inputbox" id="pass" />
                        </label></td>
                    </tr>
                    <tr>
                      <td>Email Address:</td>
                      <td><label for="confirm">
                        <input name="confirm" type="password" class="inputbox" id="confirm" />
                      </label></td>
                    </tr>
                    <tr>
                      <td><strong>Nickname:</strong></td>
                      <td><label for="nickname">
                        <input name="nickname" type="text" class="inputbox" id="nickname" />
                      </label></td>
                    </tr>
                    <tr>
                    	<td>&nbsp;</td>
                        <td><input type="submit" id="createuser" name="createuser" class="btn" value="Create User" /></td>
                    </tr>
                </table></form>
            </div>
      </div>
        <?php
		If(isset($_POST['createuser']))
		{
			include '../config.php';
			
			$user = $_POST['user'];
			$pass = $_POST['pass'];
			$confirm = $_POST['confirm'];
			$email = $_POST['email'];
			$nickname = $_POST['nickname'];
			$rank = $_POST['rank'];
			
			mysql_connect(localhost,$username, $password);
			@mysql_select_db($database) or die ("Unable to select Database");
			
			$query = "INSERT INTO users VALUES ('','$user', '$pass','$nickname','$email','$rank')";

			mysql_query($query);
		}

		?>
        
        <!-- Content Box End -->
        
         <!-- Graphs Box Start --><!-- Graphs Box End -->
        
        <!-- Alternative Content Box Start -->
        <div class="contentcontainer">
            <div class="headings altheading">
                <h2>Current Users</h2>
            </div>
            <div class="contentbox">
            	
<?php
include 'get_email.php';
?>
        <!-- Alternative Content Box End -->
    <div style="clear:both;"></div>

        <!-- Content Box Start --><!-- Content Box End -->
      <div id="footer">
       	&copy; Copyright 2011 PS3Panda</div> 
          
    </div>
    <!-- Right Side/Main Content End -->
    
        <!-- Left Dark Bar Start -->
   <?
include '../sidebar.php';
?>
    <!-- Left Dark Bar End --> 
    
    <!-- Notifications Box/Pop-Up Start --> 
    <div id="notificationsbox">
        <h4>Notifications</h4>
        <ul>
            <li>
            	<a href="#" title=""><img SRC="img/icons/icon_square_close.png" alt="Close" class="closenot" /></a>
            	<h5><a href="#" title="">New member registration</a></h5>
                <p>Admin eve joined on 18.12.2010</p>
            </li>
            <li>
            	<a href="#" title=""><img SRC="img/icons/icon_square_close.png" alt="Close" class="closenot" /></a>
            	<h5><a href="#" title="">New member registration</a></h5>
                <p>Jackson Michael joined on 16.12.2010</p>
            </li>
            <li>
            	<a href="#" title=""><img SRC="img/icons/icon_square_close.png" alt="Close" class="closenot" /></a>
                <h5><a href="#" title="">New blog post created</a></h5>
                <p>New post created on 15.12.2010</p>
            </li>
            <li>
            	<a href="#" title=""><img SRC="img/icons/icon_square_close.png" alt="Close" class="closenot" /></a>
            	<h5><a href="#" title="">New group created</a></h5>
                <p>�Web Design� group created on 12.12.2010</p>
            </li>
            <li>
            	<a href="#" title=""><img SRC="img/icons/icon_square_close.png" alt="Close" class="closenot" /></a>
            	<h5><a href="#" title="">1 new private message</a></h5>
                <p>New message from Joe sent on 21.11.2010</p>
            </li>
            <li>
            	<a href="#" title=""><img SRC="img/icons/icon_square_close.png" alt="Close" class="closenot" /></a>
            	<h5><a href="#" title="">New member registration</a></h5>
                <p>Graham joined on 20.11.2010</p>
            </li>
        </ul>
        <p class="loadmore"><a href="#" title="">Load more notifications</a></p>
    </div>
    <!-- Notifications Box/Pop-Up End --> 
    
   
    <![endif]--> 
</body>
</html>
And I then get the error of:
Quote:
Parse error: syntax error, unexpected T_LNUMBER in /home/noonhos1/public_html/cms/housekeeping/test/get_email.php on line 9
I really need help on this, all help is welcomed! Thanks!

Best Wishes,
Ptsface12
Ptsface12 is offline   Reply With Quote
Sponsored Links
Old 07-21-2011, 04:41 PM   #2 (permalink)
Regular User
 
Join Date: Jul 2005
Posts: 47
Default Re: Displaying MYSQL Data into Tables

Remove the line:
<!-- Theme Start -->
and
<!-- Theme End -->
sandman is offline   Reply With Quote
Old 09-16-2011, 04:12 PM   #3 (permalink)
Junior Member
 
Join Date: Sep 2011
Location: Long Islanf, NY, USA
Posts: 33
Default Re: Displaying MYSQL Data into Tables

Code:
print "<table width="100%">";
should be
Code:
print '<table width="100"%>';
You should only use double quotes in PHP where absolutely needed. It adds processing overhead.
Rukbat is offline   Reply With Quote
Old 09-17-2011, 01:47 PM   #4 (permalink)
Junior Member
 
Join Date: Sep 2011
Location: Canada
Posts: 7
Default Re: Displaying MYSQL Data into Tables

Quote:
Originally Posted by Rukbat View Post
Code:
print "<table width="100%">";
should be
Code:
print '<table width="100"%>';
You should only use double quotes in PHP where absolutely needed. It adds processing overhead.
Yes Use code suggested by Rukbat.
naka is offline   Reply With Quote
Old 10-06-2011, 03:47 AM   #5 (permalink)
Junior Member
 
Join Date: Sep 2011
Posts: 1
Default Re: Displaying MYSQL Data into Tables

so terrible!
TablePC111 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 08:13 AM.


Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
Webmaster Forums
Web Hosting | Chicago Web Hosting | Web Hosting