Php 从表中选择值并按while显示?
我想通过“while”选择值,但有一个问题,代码如下:Php 从表中选择值并按while显示?,php,Php,我想通过“while”选择值,但有一个问题,代码如下: <?php $following_select_article = mysql_query("SELECT * FROM follow WHERE user_follower_id='$user_id'"); while( $following_select_article_row = mysql_fetch_array($following_select_article) ) { $article_following_u
<?php
$following_select_article = mysql_query("SELECT * FROM follow WHERE user_follower_id='$user_id'");
while( $following_select_article_row = mysql_fetch_array($following_select_article) ) {
$article_following_user_id = $following_select_article_row['user_following_id'].",";
$mmnnss = substr_replace($article_following_user_id, "", -1);
$echo $mmnss;
}
执行此操作
<?php
$following_select_article = mysql_query("SELECT * FROM follow WHERE user_follower_id='$user_id'");
$article_following_user_id = "";
while($following_select_article_row = mysql_fetch_array($following_select_article)){
$article_following_user_id .= $following_select_article_row['user_following_id'].",";
}
$mmnnss = substr_replace($article_following_user_id, "", -1);
echo $mmnnss;
与
非常感谢您首先给出答案,然后是编辑我的问题:)无需substr\u替换(…)
,只需使用substr($str,0,-1)代码>
substr_replace($article_following_user_id, "", -1);
substr($article_following_user_id, 0, -1);