简体   繁体   中英

get id and echo in mysql query

i have this link floors.php?id=building1&floor1

it is showing like this

flats.php?id=Building1&1

building name and floor no

link have floor no and building name

now how can i connect in MySQL query

 $query = "SELECT * FROM floors where buildingname='$id' And 
floorno='i want here floor no how can i do this' ORDER BY floorno 

In your url should be like,

 floors.php?id=1&floorno=5

In php file,

You can use,

$id = mysql_real_escape_string($_GET['id']); //output =1. 

$floorno = mysqli_real_escape_string($_GET['floorno']); // output=5 

$query = "SELECT * FROM floors where buildingname='".$id."' and floorno='".$floorno."' ORDER BY floorno 

You may use mysqli_real_escape_string()

mysqli_real_escape_string() calls MySQL's library function mysqli_real_escape_string, which prepends backslashes to the following characters: \\x00, \\n, \\r, \\, ', " and \\x1a

Note: mysql_* deprecated Instead, the MySQLi or PDO_MySQL extension should be used

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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