Jump to content

How If WE Can Generate PHP Code By PHP Code


kanchatchai

Recommended Posts

<?PHP//Step1--------Get Database Name and Howmany Field------------//Or you can get from your database by use mysql_fetch_row($result)?><H2>Step 1 Input Get Database Name and  Number of fields</h2><form name="step1" method="GET" action="">  <table width="519" bgcolor="#FFFFCC"><tr><td colspan="2"></td></tr><tr><td width="162">db table name: </td><td width="345"><input type="text" name="table_db" /></td></tr><tr><td> Number of fields: </td><td><input type="text" name="numbfield" /></td></tr><tr>  <td></td>  <td><input name="submit1" type="submit" value = "OK" />    <input name="reset" type="reset" value = "Cancel" /></td></tr></table><a href="?">[ New Project ]</a>  <p><br />   </form><?PHP//---------Step 2 Get Field Name and Title-------------if (isset($_GET['numbfield'])&&isset($_GET['table_db'])){echo '<H2>Step 2 Input Field Name and Label</H2>';echo '<form name="step2" method="GET" action="">';$numbfield=$_GET["numbfield"];$table_db=$_GET["table_db"];for ($x = 1; $x <=$numbfield; $x++){  echo '<br>Field '.$x.' Name :<input type="textfield" name="fields_name'.$x.'">';  echo ' Field '.$x.' Title :<input type="textfield" name="fields_title'.$x.'">';}echo '<input type="hidden" name="numbfield" value='.$numbfield.'>';echo '<input type="hidden" name="table_db" value="'.$table_db.'">';echo '<br><input type="submit"  name="submit2" value = "OK">';}//---------Step 3 Generate Input Form-------------if (isset($_GET['submit2'])){?><p><strong><? echo $table_db?>_ins_f.php</strong></p><textarea rows="30" cols="80"><form name="<?PHP echo $_GET["table_db"]; ?>" method="post" action="<? echo $table_db?>_ins.php"><table border="0"><?for ($x = 1; $x <=$numbfield; $x++){?>  <tr>  <td><?echo $_GET["fields_title$x"];?></td>  <td>  <input type="textfield" name="<?echo $_GET["fields_name$x"];?>">  </td>  </tr>  <?}?>  <tr>  <td colspan="2">  <input type="reset" name="reset" value="Cancel">  <input type="submit" name="submit" value="OK">  </td>  </tr>  </table>  </form></textarea><?PHP}?>

Link to comment
Share on other sites

Changed With Download...

<?PHPif (isset($_GET["data_inf"])){//------------------------------For download------------------------download_file($_GET["table_db"].'_ins_f.php',$_GET["data_inf"]);}function download_file($filename,$file_data){			    header('Content-Disposition: attachment; filename='.$filename);			    header('Content-Transfer-Encoding: binary');			    header('Expires: 0');			    header('Cache-Control: must-revalidate');			    header('Pragma: public');			    //header('Content-Length: ' . filesize($file_data));			    //ob_clean();//Clean Header Befor Download File    echo $file_data;    //flush();    exit;}?><?PHP//Step1--------Get Database Name and Howmany Field------------//Or you can get from your database by use mysql_fetch_row($result)?><H2>Step 1 Input Table Name and  Number of fields</h2><form name="step1" method="GET" action="">  <table width="519" bgcolor="#FFFFCC"><tr><td colspan="2"></td></tr><tr><td width="162">db table name: </td><td width="345"><input type="text" name="table_db" /></td></tr><tr><td> Number of fields: </td><td><input type="text" name="numbfield" /></td></tr><tr>  <td></td>  <td><input name="submit1" type="submit" value = "OK" />    <input name="reset" type="reset" value = "Cancel" /></td></tr></table><a href="?">[ New Project ]</a>  <p><br />   </form><?PHP//---------Step 2 Get Field Name and Title-------------if (isset($_GET['numbfield'])&&isset($_GET['table_db'])){echo '<H2>Step 2 Input Field Name and Label</H2>';echo '<form name="step2" method="GET" action="">';$numbfield=$_GET["numbfield"];$table_db=$_GET["table_db"];for ($x = 1; $x <=$numbfield; $x++){  echo '<br>Field '.$x.' Name :<input type="textfield" name="fields_name'.$x.'">';  echo ' Field '.$x.' Title :<input type="textfield" name="fields_title'.$x.'">';}echo '<input type="hidden" name="numbfield" value='.$numbfield.'>';echo '<input type="hidden" name="table_db" value="'.$table_db.'">';echo '<br><input type="submit"  name="submit2" value = "OK">';}//---------Step 3 Generate Input Form-------------if (isset($_GET['submit2'])){?><p><strong><? echo $table_db?>_ins_f.php</strong></p><?PHP$insert_form='';$insert_form.='<form name="'.$_GET["table_db"].'" method="post" action="'.$table_db.'_ins.php"><table border="0">';for ($x = 1; $x <=$numbfield; $x++){$insert_form.='  <tr>  <td>'.$_GET["fields_title$x"].'</td>  <td>  <input type="textfield" name="'.$_GET["fields_name$x"].'">  </td>  </tr>  ';}$insert_form.='  <tr>  <td colspan="2">  <input type="reset" name="reset" value="Cancel">  <input type="submit" name="submit" value="OK">  </td>  </tr>  </table></form>';echo '<form name="insert_form" name="" action="GET"><textarea rows="30" cols="80" name="data_inf">'.$insert_form.'</textarea><br/>';echo '<input type="hidden" name="table_db" value="'.$table_db.'">';echo '<br><input type="submit"  name="download_ins_f" value = "download Insert Form">';echo '</form>';}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...