我的 Codeigniter 网站中有一个简单的表格,如下所示
<table class="table">
<thead>
<tr>
<th>Time</th>
<th>Image</th>
<th>Username</th>
<th>Comment</th>
<th>Action</th>
</tr>
</thead>
<tbody id="ajax_table">
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
我显示如下所示的行
public function getComment(){
$page = $_GET['page'];
$user_id =$_GET['user_id'];
// $data['comments'] = $this->member->get_all_comment($user_id);
$comments = $this->member->get_all_comment($page,$user_id);
$html='';
if(isset($comments) && count($comments)>0){
foreach($comments as $comment){
if($comment->image ==""){
$image = "https://granboardonline.com/uploads/empty.jpg";
}
else {
$image = "https://granboardonline.com/uploads/".$comment->image;
}
$html.= "<tr><td>".$comment->date_created."</td><td> <img src= $image style='width:50px;height:50px;'> </td><td>".$comment->fname."</td><td>".$comment->comment."</td>";
if($this->session->userdata('user_id')==$comment->reciver_id || $this->session->userdata('user_id')==$comment->sender_id){
$html.="<td><button class='btn btn-light btn-sm deletecomment' comment_id='".$comment->comment_id."'>Delete</button></td></tr>";
}
}
}
echo $html;
exit;
}
Run Code Online (Sandbox Code Playgroud)
但是我的评论栏的行走到外面,看起来很糟糕,我如何才能显示它适合该栏?
谢谢!
我试图在我的 PHP 页面上获取所有条纹订阅者的列表。
到目前为止,我已经设法从条带 API 返回的数组中获取了 1 个订阅者的详细信息。
但是当我尝试获取 2 或 3 个等订阅者的详细信息时,我什么也没得到。
我知道我需要使用循环或每个循环来实现这一点,但我不知道如何。
这是我当前获取 1 个订阅者详细信息的代码:
$data = \Stripe\Subscription::all(['limit' => 1]);
$sub_id = $data->data[0]->id;
echo $sub_id;
Run Code Online (Sandbox Code Playgroud)
现在我需要获取超过 1 个订阅者的详细信息,所以我尝试了这个,但它不起作用并且不返回任何内容(也没有错误):
$data = \Stripe\Subscription::all(['limit' => 2]);
foreach ($data as $k => $v) {
echo $data->data[0]->id;
}
Run Code Online (Sandbox Code Playgroud)
有人可以就这个问题提出建议吗?