简体   繁体   English

如何从数据库表中显示我的ID号?

[英]how to display my id number from db table?

I'm a student studying web programming im trying to display some of information from my db table which are(name, date, dll), all of the information are displayed perfectly except my id number from the db table and also there are no error so its hard for me to detect what i did wrong. 我是一名正在学习网络编程的学生,我试图显示我的数据库表中的一些信息(名称,日期,dll),所有信息都完美显示,除了我的数据库表中的ID号,而且也没有错误因此,我很难发现自己做错了什么。 can anyone see what i did wrong in my coding and explain what have i missed? 谁能看到我在编码中做错的事情并解释我错过了什么?

for further reference this is my php coding: 供进一步参考,这是我的php编码:

<?php   

$con = mysql_connect("localhost", "root", "");
mysql_select_db("tempahperalatan");


if(isset($_POST['hantar']))
{

    $noID = 'noID';
    $pemohon = $_POST['pemohon'];
    $trkhMula = $_POST['trkhMula'];
    $trkhAkhir = $_POST['trkhAkhir'];
    $n_program = $_POST['n_program'];
    $lokasi = $_POST['lokasi'];
    $n_anjuran = $_POST['n_anjuran'];
    $catatan = $_POST['catatan'];
    $masa = $_POST['masa'];
    $t_Log = $_POST['t_Log'];
    $modified_date;
    $modified_time;

$sql = "INSERT INTO daftartempah (pemohon, trkhMula, trkhAkhir, n_program, lokasi, n_anjuran, catatan, modified_date, modified_time) VALUES ('$pemohon', '$trkhMula', '$trkhAkhir', '$n_program', '$lokasi', '$n_anjuran', '$catatan', CURDATE(), CURTIME())";  
$res = mysql_query($sql);   
}

    $viewPerson = "SELECT * FROM daftartempah";
    $viewPersonRes = mysql_query($viewPerson);

?>

and this is a table im trying to display some of my info from my db table: 这是一个表,即时通讯试图显示我的数据库表中的一些信息:

<?php


while($row = mysql_fetch_array($viewPersonRes)){

    echo "<tr>";
        echo "<td".$row['noID']."</td>";
        echo "<td>".$row['trkhMula']."</td>";
        echo "<td>".$row['modified_time']."</td>";
        echo "<td>".$row['n_program']."</td>";
        echo "<td>".$row['pemohon']."</td>";
        echo "<td>".$row['n_anjuran']."</td>";
        echo "<td>".$row['lokasi']."</td>";
        echo "<td>".$row['catatan']."</td>";
    echo "</tr>";
}
?>

my table name from my db is: daftartempah 我的数据库中的表名称是:daftartempah

thank you in advance, your help is much needed :) 在此先感谢您,非常需要您的帮助:)

You have a missing closure for your <td> tag. 您的<td>标签缺少闭包。

echo "<td".$row['noID']."</td>";
         ^ right there.

That's why it's not displaying. 这就是为什么它不显示。

Therefore: 因此:

echo "<td>".$row['noID']."</td>";

and looking at your developer console and the HTML source would have shown you something about it. 并查看您的开发者控制台,HTML源代码将向您显示一些相关信息。

Make sure that you also have the opening and closing <table> - </table> tags. 确保您还具有开始和结束<table> - </table>标记。 That's unknown. 不知道

You're also practicing with an outdated API, which isn't good practice to begin with. 您还正在使用过时的API进行练习,这并不是一开始的好习惯。

Use either the mysqli_ or PDO API for "this century". 在“本世纪”中使用mysqli_或PDO API。

You're also open to an serious SQL injection; 您还可以进行认真的SQL注入。 use a prepared statement: 使用准备好的语句:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM