如何在php中连接一个字母和一个数字

时间:2017-02-20 07:16:49

标签: php mysql

我的PHP代码:

$dbquery="create view vdata as select concat('P','$id') as id,company_name,contact_person,phone,address,email,quantity,area,mode_of_payment,cost from data order by id DESC;";

$dbquery1="select * from vdata order by id DESC; ";

$result1=mysql_query($dbquery1,$db)or die("cant query 1"); 

id应该像P1一样。但它没有工作。它显示id = 1。

3 个答案:

答案 0 :(得分:0)

你可以这样做:

$dbquery="create view vdata as select P".$id." as id,company_name,contact_person,phone,address,email,quantity,area,mode_of_payment,cost from data order by id DESC;";

答案 1 :(得分:0)

没有代码可以执行$dbquery的内容,因此您的视图不存在或者可能存在于与您想要的版本不同的旧版本中

答案 2 :(得分:-2)

$dbquery="create view vdata as select concat('P',id) as 
id,company_name,contact_person,phone,address,email,quantity,area,mode_of_payment,cost 
from data order by id DESC;";

mysql_query($ dbquery,$ db)或死("无法查询视图");