1

我有两个要从中选择的表 1 我想获取用户信息 2 我想获取属于该用户的所有图像。但查询不检索图像,但在查询窗口中我得到它们。如果我决定从图像表中选择图像,也会在脚本中显示图像,但是当我执行连接时它不起作用。我知道有些事情做得不好。请任何帮助将不胜感激波纹管是代码

$query='SELECT 
tish_clientinfo.lastname, tish_clientinfo.address,
tish_clientinfo.firstname,
tish_images.image_name
  FROM  tish_clientinfo 
  INNER JOIN tish_images 
ON tish_clientinfo.user_id = tish_images.user_id
 WHERE user_id= '. intval($_GET['user_id']);
$result = $con->prepare($query);
$result->execute();
4

2 回答 2

2

可能是服务器弄糊涂了user_id。试试这个

$query='SELECT 
tish_clientinfo.lastname, tish_clientinfo.address,
tish_clientinfo.firstname,
tish_images.image_name
  FROM  tish_clientinfo 
  INNER JOIN tish_images 
ON tish_clientinfo.user_id = tish_images.user_id
 WHERE tish_clientinfo.user_id= '. intval($_GET['user_id']);
于 2013-02-26T07:51:45.667 回答
1

在 user_id 上的 where 子句指定表之后,您只是遇到了一个小问题,就像我在下面的答案中所做的那样

$query='SELECT 
tish_clientinfo.lastname, tish_clientinfo.address,
tish_clientinfo.firstname,
tish_images.image_name
  FROM  tish_clientinfo 
  INNER JOIN tish_images 
ON tish_clientinfo.user_id = tish_images.user_id
 WHERE tish_clientinfo.user_id= '. intval($_GET['user_id']);
$result = $con->prepare($query);
$result->execute();
于 2013-02-26T07:53:13.490 回答