0

hello every one i have created a code to create html table from php. simply user enter column and row no. and submit.
this data will create a table for the same.

now i want to put some names with this table. like each table column have a name from other sql table. i have tried a lot but both
these things not working together. when only sql query works and table will not be created if i stop sql query then table will be created.

please help me to do this.

code is:-

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Marks Sheet</title>
<script type="text/javascript">
function mess()
{
window.alert("First row must be used for Column Heading");
}

</script>



</head>

<body onLoad="mess()">
<?php

$exam=$_POST['exam'];
$sub=$_POST['sub'];
$col=$_POST['col'];
$row=$_POST['row'];

/*echo $exam; echo "<br>";
echo $sub; echo "<br>";
echo $col; echo "<br>";*/

echo "<p align='center'<b><font size='+2'>". $exam . "</font></b></p>";
echo "<p align='center'<b><font size='+1'>". $sub . "</font></b></p>";



$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("marks", $con);

$result = mysql_query("SELECT * FROM vi");

 while($row = mysql_fetch_array($result))
  {
  echo $row['1'];
  echo "<br />";
  }

mysql_close($con);

echo"<div align='center'";
echo "<form name='sheet' action='csheet.php' onsubmit='return check()' method='post'>";

echo"<table width='200' border='1'>";

for($a=1;$a<=$row;$a++)
{

echo"<tr bgcolor='#0099FF'>";
    for($b=1;$b<=$col;$b++)
    {   

    echo"<td><input type='text' name='' size='8' /></td>";

    }

 echo"</tr>";

}

echo"</table>";
echo "<input type='submit' value='Submit'>";
echo "</form></div>";

?>
</body>
</html>

Edited by diafol: apply code tags

2
Contributors
1
Reply
15
Views
5 Years
Discussion Span
Last Post by whiteyoh
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.