[英]Displaying data in table foreach loop
I am calling github api
to list all the issues I have in my repo. 我正在打电话给github api
列出我在github api
所有问题。
I want to list these issues in table form on my site... 我想以表格形式在我的网站上列出这些问题...
However I cannot get the table going with my foreach loop. 但是我无法让表与我的foreach循环一起使用。
Here is my PHP code: 这是我的PHP代码:
<?php
ini_set('user_agent', 'PHP');
$json = file_get_contents("https://api.github.com/repos/stroes/stroestest/issues");
$data = json_decode($json);
foreach ($data as $i) {
// echo $i->number.";".$i->state.";".$i->title.";".$i->body."\n\r";
echo "<tr><td>".$i->number."</td><td>".$i->state."</td><td>".$i->title."</td><td>".$i->body."</td></tr>";
}
?>
You are missing table tag. 您缺少表格标签。 so try this 所以试试这个
ini_set('user_agent', 'PHP');
$json = file_get_contents("https://api.github.com/repos/stroes/stroestest/issues");
$data = json_decode($json);
echo "<table>" ;
foreach ($data as $i)
{
// echo $i->number.";".$i->state.";".$i->title.";".$i->body."\n\r";
echo "<tr><td>".$i->number."</td><td>".$i->state."</td><td>".$i->title."</td><td>".$i->body."</td></tr>";
}
echo "</table>" ;
Table tag is not there, try this 表标签不存在,请尝试此
ini_set('user_agent', 'PHP');
$json = file_get_contents("https://api.github.com/repos/stroes/stroestest/issues");
$data = json_decode($json); ?>
<table>
<?php
foreach ($data as $i)
{
echo "<tr><td>".$i->number."</td><td>".$i->state."</td><td>".$i->title."</td><td>".$i->body."</td></tr>";
?>
<tr>
<td> ?>
<?php echo $i->number ?>.
</td>
<td> ?>
<?php echo $i->state ?>.
</td>
<td> ?>
<?php echo $i->title ?>.
</td>
<td> ?>
<?php echo $i->body ?>.
</td>
</tr>
<?php
}
?>
</table>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.