Try this:
echo"<table border=1 width=100%>";
for ($x=1; $x < $inputnum + 1; $x++)
{
if (strlen($x) > 1)
{
$lastdigit = substr($x, -1);
}
else
{
$lastdigit = $x;
}
if ($lastdigit == 1 || $lastdigit == 6)
{
echo"<tr>";
}
echo"<td><input type='text' name='input[$x] $lastdigit></td>";
if ($lastdigit == 0 || $lastdigit == 5)
{
echo"</tr>";
}
}
echo"</table>";