0
我得到了這個腳本,他是我返回我的數據庫的所有表,就像知道我怎麼只看到表「CITY_NAME」我的數據庫。如何查詢此信息
我很欣賞的人誰可以幫我
<?php
//Configure the MySQL conwection
$host = 'localhost';4
$user = 'root';
$password = '';
$database = 'ip2location';
$table_name = 'ip2location_db3';
//Get the visitor IP address
$ip = $_SERVER['REMOTE_ADDR'];
//In case you are testing locally with 127.0.0.1,
//you can uncomment the below line to assign the IP address
//to 8.8.8.8 (or whatever) for your testing.
$ip = '8.8.8.8';
try{
//Create and perform the SQL query using the PDO
$db = new PDO('mysql:host=' . $host . ';dbname=' . $database . ';charset=utf8', $user, $password);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$st = $db->prepare('SELECT * FROM `' . $table_name . '` WHERE INET_ATON(:ip) <= ip_to LIMIT 1');
$st->execute(array(':ip'=>$ip));
$row = $st->fetch(PDO::FETCH_ASSOC);
//Print out the result
var_dump($row);
}
catch(PDOException $e) {
echo $e->getMessage();
}
?>
我建議你開始閱讀對sql語言的基本介紹。然後你可以自己輕鬆回答你的問題。 – arkascha
'CITY_NAME'是您的餐桌名稱或列名稱 – urfusion
您是對的。這是專欄 –