出于某种原因,我正在尝试创建的表格未显示在我的页面上。页面使用完美,我无法弄清楚为什么它现在不起作用。
我的程序仅在我设置
时有效$_SESSION['loginname']="jordan@yahoo.com";
or $_SESSION['loginname']="mary666@yahoo.com";
等等。
我已经在我的上一页上创建了一个名为$_SESSION['loginname'];
的“$ _Session”我一遍又一遍地回应会话,看看它是否正在从一个页面传递到另一个页面当前页面确实如此。
为什么我的$ _SESSION不允许我的MYSQL代码运行循环来显示我的数据库中的数据?代码如下:
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<title>User Account</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<div id="main">
<header>
<div id="welcome">
<h2>Prairie View A&M University</h2>
</div><!--close welcome-->
</header>
<nav>
<div id="menubar">
<ul id="nav">
<li><a href="index.php">Home</a></li>
<li class="current"><a href="user-account.php">Account Info</a></li>
<li><a href="quiz_main.php">Quiz</a></li>
         
<?php
if($_SESSION['loginname'])
echo $_SESSION['loginname'].", "."<a href='user-account.php'>Account</a>"." "."<a href='logout.php'>Logout</a>";
else
die("You must login");
?>
</ul>
</div><!--close menubar-->
</nav>
<div id="site_content">
<?php
$username = "root";
$password = "";
$hostname = "localhost";
$database = "basketball_database";
$table = "users";
$session_login = $_SESSION['loginname'];
$con = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MYsql");
// echo "Connected to mysql<br>";
mysql_select_db("$database")
or die("Could not select Basketball_database");
//echo "Connected to database";
$mysql = "SELECT * FROM $table WHERE login_name='$_SESSION[loginname]'";
$mydata = mysql_query($mysql,$con);
while($records = mysql_fetch_array($mydata)){
//create table
echo "<table border=1
<tr>
<th>User ID</th></tr>
<tr>
<th>Login Name</th></tr>
<tr>
<th>Password</th></tr>
<tr>
<th>Last Name</th></tr>
<tr>
<th>First Name</th></tr>
<tr>
<th>Account Type</th>
</tr>";
echo "<tr>";
echo "<td>".$records['user_ID']."</td>";
echo "<td>".$records['login_name']."</td>";
echo "<td>".$records['password']."</td>";
echo "<td>".$records['last_name']."</td>";
echo "<td>".$records['first_name']."</td>";
echo "<td>".$records['type']."</td>";
echo "</tr>";
} echo "</table>";
mysql_close();
?>
<div id="content">
<div class="content_item">
</div><!--close content_container-->
</div><!--close content_item-->
</div><!--close content-->
</div><!--close site_content-->
<footer>
<a href="index.php">Home</a> | <a href="photos.php">Photos</a> | <a href="videos.php">Videos</a> | <a href="schedule.php">Schedule</a> | <a href="contact.php">Contact</a><br/><br/>
</footer>
</div><!--close main-->
<!-- javascript at the bottom for fast page loading -->
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/image_slide.js"></script>
</body>
</html>
我意识到我的桌子看起来像这样
User ID
Login Name
Password
Last Name
First Name
Account Type
1321 jordan@yahoo.com 21duncan oneal jordan athlete