Php Programming Code Examples
Php > Arrays Code Examples
Create a grid out of INPUT TYPE=TEXT then saving to a database. Uses
Create a grid out of INPUT TYPE=TEXT then saving to a database. Uses
use this bit of code to create a grid
<?
for($r=1;$r<=$NoRows;$r++){
echo"<TR>";
for($c=1;$c<=$NoCols;$c++){
echo"<TD ALIGN=CENTER>";
echo"<INPUT TYPE=\"TEXT\" SIZE=\"7\" NAME=\"Field[[$r][$c]]\"></TD>";
}
echo"</TR>";
}
?>
now put in the database like this
<?
for($i=1;$i<=$NoRows;$i++){
$sql="INSERT INTO RateTable".$TableName." VALUES(".$i;
for($j=1;$j<=$NoCols;$j++){
$sql=$sql.",".($Field["[$i][$j]"]);
}
$sql=$sql.")";
echo"<P>".$sql."</P>";
if(!mysql_db_query("wilrus",$sql)){
echo"<P>Major problem, sorry</P>";
}else{
echo"<P>Row ".$i." created.</P>";
}
}
?>