网址:
empdetail.php?id=1
我的 MySQL 数据库中有两个表。我想合并两个表,我想我做到了。_GET['id']
$或其他代码中可能存在一些问题。当我单击empdetail.php?id=1
时,结果显示完美。当我单击empdetail.php?id=2
或empdetail.php?id=3
等时,没有显示任何结果。我不知道为什么它没有显示任何结果。
<?
//////Displaying Data/////////////
//connect to database
mysql_connect('localhost','root','');
mysql_select_db('cdcol');
$id=$_GET['id']; // Collecting data from query string
if(!is_numeric($id)){ // Checking data it is a number or not
echo "Data Error";
exit;
}
$result = mysql_query("SET NAMES utf8"); //the main trick
$query = "SELECT ospos_employees.person_id, ospos_people.first_name ".
"FROM ospos_employees, ospos_people ".
"WHERE ospos_employees.person_id = ospos_people.person_id='$id'";
$result = mysql_query($query) or die(mysql_error());
// Print out the contents of each row into a table
while($row = mysql_fetch_array($result)){
echo $row['person_id']. " - ". $row['first_name'];
echo "<br />";
}
?>