简体   繁体   English

SQL语句似乎正常工作,但未显示在网站php SQL上

[英]SQL Statement appears to work but doesnt display on website php SQL

hello im doing a website that sells games as a project and one of my problems is that i cant seem to display a value from the database on phpmyadmin onto the webpage, no errors are flagging up when i go on the page i want the value to be displayed so im presuming its working to some degree. 你好,我正在做一个网站,将游戏作为项目出售,我的问题之一是我似乎无法在phpmyadmin上将数据库中的值显示到网页上,当我进入该页面时,我没有错误提示我想要该值进行显示,以便在某种程度上假定其正常工作。

I have also entered the query into phpmyadmin to test it to see if there are any errors, but it displayed none and did the SELECT query just fine and outputted the desired result. 我也将查询输入到phpmyadmin中以对其进行测试以查看是否存在任何错误,但是它没有显示任何内容,并且SELECT查询是否正常并输出了所需的结果。

Here is my query statement at the top of the page 这是我在页面顶部的查询语句

$query = "SELECT rectable.gameID, rectable.gameIMG, rectable.gamePrice, rectable.gameName, members.country, basket.quantity FROM rectable INNER JOIN basket 
ON rectable.gameID=basket.gameID INNER JOIN members ON basket.id=members.id

It outputs the following 它输出以下内容

http://gyazo.com/1a33408ce0c2bf67a98c08f98624c539

basically im trying to get the Country from the database and display it. 基本上,我试图从数据库中获取国家/地区并将其显示出来。

My code within php is this 我在PHP中的代码是这样的

<?php
$count = 0;
while ($count < $numrow)
{
$row = $results -> fetch_assoc();
extract($row);
echo"<div>";
echo"<div id='recommended_games2'>";
echo "<img src='images/".$gameIMG."' />";
echo "</div>";


echo '<div id="price_tag2">';
echo '<div class="price_tag" name="price" method="POST">£'.$gamePrice. '</div>';
echo'</div>';

echo '<div id="quantity_tag">';
echo '<div id="quantity_tag" >Quantity  '.$quantity.'</div>';
echo'</div>';

echo"<img class='box1' src='Images/Grey-Banners.png' />";
echo"</div>";
$count = $count + 1;  


}     
echo '<div id="delete_all">';
echo '<form action="cart.php">';
echo '<input id="hide_button" type="submit" value="Edit Cart"  />';
echo '</form>';
echo '</div>';

echo '<div id="totalprice">';
echo '<form action="" method="POST">';
echo '<input type="submit" value="Order Items"  />';
echo '</form>';
echo '</div>';

echo '<div id="address" >'.$country.'</div>';


?>

It displays the website something like this 它显示网站是这样的

http://gyazo.com/75bafd47229f0521fb1868941e5f5f27

But as you can see i cant get the country to be displayed. 但是如您所见,我无法显示该国家。

try to change your loop like the following: 尝试如下更改循环:

while ($row = $results -> fetch_assoc()) {
    echo"<div>";
    echo"<div id='recommended_games2'>";
    echo "<img src='images/".$row['gameIMG']."' />";
    echo "</div>";


    echo '<div id="price_tag2">';
    echo '<div class="price_tag" name="price" method="POST">£'.$row['gamePrice']. '</div>';
    echo'</div>';

    echo '<div id="quantity_tag">';
    echo '<div id="quantity_tag" >Quantity  '.$row['quantity'].'</div>';
    echo'</div>';

    echo"<img class='box1' src='Images/Grey-Banners.png' />";
    echo"</div>";
    echo '<div id="address" >'.$row['country'].'</div>';
}

I'm not sure here, but you have "INNER JOIN members ON basket. id =members.id" in your code while you joined basket on rectable with gameID. 我不知道在这里,但你有“INNER JOIN成员篮子。ID = members.id”在你的代码,而你在rectable加入篮游戏ID。 Do you have two different ID columns in your "basket" table? 您的“购物篮”表中是否有两个不同的ID列?

Thank you all for you help but i have realised the problem which i think brian driscoll sort of answered, Basically it was basically working but the reason for it not displaying is because in my database i only entered the address for one of the users and for it to be displayed you had to be logged on as that user, since i have set up session variables and ids which meant each cart was specific to the user. 谢谢大家的帮助,但我已经意识到我认为是brian driscoll回答的问题,基本上它基本上可以正常工作,但是不显示的原因是因为在我的数据库中,我只输入了一个用户的地址,并且要显示它,您必须以该用户身份登录,因为我已经设置了会话变量和ID,这意味着每个购物车都是特定于该用户的。 Which meant only the country that was associated with the user was displayed. 这意味着仅显示与用户关联的国家/地区。

Thanks for the help guys 谢谢你们的帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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