【发布时间】:2014-04-22 11:43:06
【问题描述】:
我需要帮助我的 php 程序找到一个素数。这是我的代码:
<form method="post" action="">
<table border="1" width="180px">
<thead>
<tr bgcolor="yellow">
<th>#</th>
<th>Data 1</th>
<th>Data 2</th>
<th>Data 3</th>
</tr>
</thead>
<?php
error_reporting(0);
$start = 21;
$n_rows = 5;
$n_cols = 4;
for ($i = 0; $i < $n_rows; $i++) {
$row = '';
for ($j = 0; $j < $n_cols; $j++) {
$row .= '<td>'. ($start + $i + ($j * $n_rows)). '</td>';
}
$out .= '<tr>'. $row. '</tr>';
}
echo $out;
?>
<tr>
<td colspan=4>
<center>
<label for="input">Initial value:</label>
<input type="text" name="awal" style="width: 60px">
<input type="submit" name="submit" value="Send">
</center>
</td>
</tr>
</table>
</form>
问题是,如何检查我们是否输入了输入的初始值来查找素数?如果是素数,则数字将为红色,如果不是素数,则为黑色。
我需要代码来制作它,任何回复将不胜感激。
【问题讨论】:
-
它没有回答我的问题@Raphioly-San
标签: php for-loop html-table numbers