简体   繁体   English

选择所有带有sport = padel的行

[英]select all rows with sport=padel

I want to select all the content of the row when sport= padel. 当sport = padel时,我想选择该行的所有内容。

My code is this: 我的代码是这样的:

$result = mysqli_query($con,"SELECT sport FROM posts WHERE sport='padel'                
 ");
while($row=mysqli_fetch_assoc($result)){ ?>

<div  class= 'box1'>
<p align='middle'><?php echo $row['username']; ?></p>
<h3 align='middle'>Playing</h3>
<h3 align='middle' style= 'color:blue'><?php echo $row['sport']; ?> </h3>
<div><p align='middle' >Disponibilidade:</p>
<h3 align='middle' style='color:blue'><?php echo $row['text']; ?></h3></div>
<p></p>
<h3 align='middle' style='color:blue'><?php echo $row['city']; ?></h3>
<button text-align='middle' id='submit1' type='submit1'> 
contact </button>
</div>

This, in fact, select all the row with sport=padel, but all the other content in the different columns is missed (gives me undefined variable) 实际上,这选择了Sport = padel的所有行,但是错过了不同列中的所有其他内容(给我未定义的变量)

I think I could do this: 我想我可以这样做:

 $result = mysqli_query($con,"SELECT sport FROM posts WHERE sport='padel'                
 WHERE text='' WHERE city=''");

but didn't work. 但是没有用 Can anyone help me? 谁能帮我?

As others have mentioned in the comments, you need to specify what columns you want to pull back, at the moment you are pulling back the sport column only. 正如其他人在评论中提到的那样,您只需要在退回运动栏时指定要回退的栏。

SELECT * FROM posts WHERE sport="padel"

This will ensure you pull back all columns. 这将确保您撤回所有列。 Alternatively you can specify multiple comma separated columns 或者,您可以指定多个逗号分隔的列

SELECT col1, col2, col3 FROM posts WHERE sport="padel"

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

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