dongxuan1314 2012-02-16 00:53
浏览 127

从mysql获取数据以显示在网页上

<?php
session_start(); // First thing... every time
require_once("connect.php");    if(!isset($_SESSION['username'])){
header('Location: login.php'); the top
exit; // Always include after redirect.
 }
if(isset($_POST['submit'])){

 $sql = "UPDATE user SET attendance1 = '" . mysql_real_escape_string($_POST['attendance1']) . "' WHERE username = '" . mysql_real_escape_string($_SESSION['username']) . "'";
 mysql_query($sql) or die("Error in SQL: " . mysql_error());  

 $query="SELECT lastname FROM user WHERE username = " . $_SESSION['username'] . ";"; 
 $result=mysql_query($query); 
   $row = mysql_fetch_assoc($result); 
  $_SESSION[lastname] = $row[lastname]; 
 header("Location: thankyou.html", true, 303); // Look up "303: See Other"
   exit;
 }
?>

above is my php code. What i want to do is display the lastname from the database onto the webpage.

code on webpage is

Welcome <?php echo $_SESSION['lastname']; ?>.

the issue is that the lastname is not displayed after welcome

  • 写回答

3条回答 默认 最新

  • dongyaofu0599 2012-02-16 01:14
    关注

    i see that u r just getting the display i.e., select display from table. if you need lastname and display then you should be doing Select display,lastname from user.

    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100