I run this code, and got this error:
Parse error: syntax error, unexpected T_LNUMBER in C:\xampp\htdocs\Generate.php on line 5
What is the problem?
<?php
$satr=$_POST["satr"];
$soton=$_POST["soton"];
$bg=$_POST["bg"];
echo ("<table border="1" style="background-color:$bg">");
for($i=1;&i<=$satr;$i++)
{
echo("<tr>");
for($j=1;j<=$soton;$j++)
{
echo("<td>$soton</td>");
}
echo("</tr>");
}
echo("</table>");
?>
You are not escaping the quotes in the string. You need to do something like this:
echo ("<table border=\"1\" style=\"background-color:$bg\">");
Can you try this, you have used &i
in for loop, you need to use $i
$satr=$_POST["satr"];
$soton=$_POST["soton"];
$bg=$_POST["bg"];
echo ("<table border='1' style='background-color:$bg'>");
for($i=1;$i<=$satr;$i++)
{
echo("<tr>");
for($j=1;j<=$soton;$j++)
{
echo("<td>$soton</td>");
}
echo("</tr>");
}
echo("</table>");
You dont need the parenthesis and you need to escape you inner double quotes
<?php
$satr=$_POST["satr"];
$soton=$_POST["soton"];
$bg=$_POST["bg"];
echo "<table border=\"1\" style=\"background-color:$bg\">";
for($i=1;&i<=$satr;$i++)
{
echo "<tr>";
for($j=1;j<=$soton;$j++)
{
echo "<td>$soton</td>";
}
echo "</tr>";
}
echo "</table>";
?>
Also look here What is the difference between single-quoted and double-quoted strings in PHP?
echo ("<table border='1' style='background-color:$bg'>");
echo ('<table border="1" style="background-color:$bg">');
echo "<table border=\"1\" style=\"background-color:$bg\">";
echo '<table border="1" style="background-color:$bg">';
echo "<table border='1' style='background-color:$bg'>";