从mysql获取数字到php变量

时间:2014-11-13 17:50:46

标签: php mysql arrays get

我在mysql数据库中有一个数字 这是我的代码:

$servername = "xxxxx";
$username = "xxxxxx";
$password = "xxxxxx";
$dbname = "xxxxxx";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 



$sql1 = "SELECT date FROM test";
$result1 = $conn->query($sql1);
$res1 = mysqli_fetch_assoc($result1);
echo $res1['date'];

我想将该数字加载到变量中并使用该变量进行计数。之后,我会将db和table存储在同一个地方

1 个答案:

答案 0 :(得分:0)

$numvar = $res1['date'];

有呀。