0 Replies - 185 Views - Last Post: 05 October 2012 - 06:24 AM Rate Topic: -----

#1 mayuribabar2@gmail.com  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 05-October 12

To save runtime created table data into Database

Posted 05 October 2012 - 06:24 AM

<?php
global $Host;
global $Username;[attachment=31162:svRutmTable.php]
global $password;
global $database;

function getConnection()
{
	$Host = "localhost";
	$Username = "root";
	$password = "";
	$database = "labdata";
	
	$oMysqli = new mysqli($Host,$Username,$password,$database);
  // return($oMysqli);
}
?>
<?php
// include_once "dreportCreation.php";
  function displaydata($column,$rows)             
	{       
      echo "<table border='1' align='center'>";           
      for($i = 0;$i<$_POST['column'];$i++)       
		{ 
            echo "<tr>".$i."</tr>";                              
            for($j = 0; $j <$_POST['rows'];$j++)         
            {
             echo "<td>" ."<input type=\"text\" name='column_$i[$j]'>"."</td>"; 
            }
		}
       echo "</table>";
	   echo "<input type=\"submit\" name=\"ok\" value=\"ok\" onclick=\"add()\">";
	 //function displaydata($column = NULL) {if($id == NULL) Event::run('system.52');}
  }
  ?>
    <html>
    <head>
    <title>aa</title>
    </head>
    <body>
    <form name="reportCreation" method="post">
                        <label for='Table'>Define Table</label>
                        
						<label for='column'>Row</label>
						<input type="text" name="column"></input>
						
						<label for='rows'>Column</label>
                        <input type="text" name="rows"></input>
                        
						<input type="submit" name="submit" value="submit" onclick="displaydata();">
						
			
			<!--$plength = count($_POST['instrument_codes']);
			for($j=0;$j<$plength;$j++)
						{
						   $b = $_POST['instrument_codes'][$j];
						   
						   $pa = array('instrument_codes' => $b['instrument_codes']);
							
						   foreach($pa as $l => $m)
							{
								$pa[$l] = mysql_real_escape_string($m);
								
							}
						$Instrumentcodes = $pa['instrument_codes'];
						$Instrumentcodes = $_POST['instrument_codes'][$j];
					   }
			--->
 </form>

<?php 
	if(isset($_POST['submit']))displaydata();// Show data INSIDE form
if(isset($_POST['ok']))displaydata();
	{
		function add()
		{
			$length = count($_POST['rows']);
			for($k=0;$k<$length;$k++)
			{
				$a = $_POST['rows'][$k];
				$na =array('rows' => $a['rows']);
				foreach($na as $l => $m)
				{
				 $na[$k] = mysql_real_escape_string($m);
				}
				$rows = $na['rows'][$k];
				$rows = $_POST['rows'][$k];
				
//				print_r($rows);exit();

				$InsertQuery = "INSERT INTO rct(testname,result,unit,NormalRange) VALUES('$testname','$result','$unit','$NormalRange')";
				$oMysqli = getConnection();
				$oMysqli->query($InsertQuery);

			}
	   }
	}
?>
</body>
</html>

Attached File(s)



Is This A Good Question/Topic? 0
  • +

Page 1 of 1