一個特定的值,我想從一個MySQL數據庫的值。我需要搶價格爲特定的項目,這裏是我的表的樣子:抓住從MySQL數據庫
我不知道如何去了解這一點,我能想到的唯一搶表中的價格是通過向查詢添加一個條件來獲得的,只有匹配結果匹配domain_address
。
我通過調用返回http://vauxhallpartswarehouse.co.uk/
(應該匹配針對數據庫錄入功能<?php echo getPageURL();?>
做了測試。
//table which calls function
<td bgcolor="#999999" align="center">Price: <?php echo getPrice();?></td>
<?php
function getPrice() {
$con=mysqli_connect("host","user","pass","db");
$price = mysqli_query($con, "SELECT price FROM domains WHERE domain_address='<?php echo getPageURL();?>'");
mysqli_close($con);
return $price; //should only be 1 result returned since domain_address is unique
}
?>
這似乎並不想工作,我真的不知道如何獲得價格
我知道連接是好的,我已經有了這個代碼進一步向下創建一個表與數據庫的所有結果的表,所以也許我可以做一些與下面的代碼?
<?php
$con=mysqli_connect("host","user","pass","db"));
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$results = mysqli_query($con, "SELECT domain_name, domain_address, price FROM domains");
echo "<table border='1'>
<tr><th>Domain</th>....
</tr>";
while($row = mysqli_fetch_array($results))
{
echo "<tr>";
echo "<td>" . $row['domain_name'] . "</td>";
echo "<td><a target='_blank' href=" . $row['domain_address'] . ">"....
//etc
mysqli_close($con);
?>
你應該考慮改變你的mysql憑據,因爲你剛剛在互聯網上發佈它們。我已經爲你編輯了 – baao 2014-10-28 12:08:19
@ donald123他們是假的 – 2014-10-28 12:10:03
@ donald123'無法連接到MySQL:連接超時' – andrew 2014-10-28 12:11:16