一个特定的值,我想从一个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