0

如何在 SQL 查询中将字符串与 PHP 变量连接起来?

例子:

select User from users where id="badge_name""$user_id"

请写一个badge_nameuser_id字符串连接的代码示例。其实我忘了我上次是怎么做到的,就像“你好”。用其他一些字符串。请更具体...谢谢

4

2 回答 2

1
<?php
$sql_query = "
SELECT 
    `User` 
FROM 
    `users` 
WHERE 
     `id` = '" . $badge_name . $user_id "'
";
?>
于 2013-05-12T05:32:35.873 回答
1
$id = "badge_name".$user_id;

mysqli_query("select User from users where id='$id'");
于 2013-05-12T05:34:49.480 回答