PHP側からWebサイト全体を動的に作成する制限はありません最良の例は、コードの下のCMSです。PHP側からそのロジックがどのように作成されるかを彼を助けようとしています
admin_rights.php
<!--<script src="http://code.jquery.com/jquery-1.7.2.js"></script>-->
<script>
function dynamic_field(type,div_no){
if(type == 'text'){
document.getElementById('dynamic_field_'+div_no).innerHTML='TextField Name : <input type = "text" name="txt_field"> -> your text field has been generated just define name';
}else if (type == 'textarea'){
document.getElementById('dynamic_field_'+div_no).innerHTML='TextArea Name : <input type = "text" name="text_area"> -> your text area has been generated just define name';
}else if (type == 'table_name'){
document.getElementById('dynamic_field_'+div_no).innerHTML='Table Name : <input type = "text" name="table_name"> -> your table has been generated just define name';
}
}
</script>
Admin Rights <br />
<form action="action.php" method="post">
<input type="button" value="TextField" onclick="dynamic_field('text',1)" />
<input type="button" value="TextArea" onclick="dynamic_field('textarea',2)" />
<input type="button" value="Table Name" onclick="dynamic_field('table_name',3)" />
<br />
<?php
for($i = 1; $i<=10; $i++){
?>
<div id="dynamic_field_<?php echo $i;?>"></div>
<?php
}
?>
<input type="submit" value="submit" />
</form>
アクション.php
<pre>
<?php
$con = mysql_connect("localhost","root","");
if (!$con){
die('Could not connect: ' . mysql_error());
}
mysql_select_db("dynamic_form", $con);
mysql_query("
CREATE TABLE
`dynamic_form`.`".$_REQUEST['table_name']."`
( `id` INT(11) NOT NULL AUTO_INCREMENT , `".$_REQUEST['txt_field']."` VARCHAR(225) , `".$_REQUEST['text_area']."` TEXT , PRIMARY KEY (`id`)) ;")
?>
Congrulation you have successfully generated <?php echo $_REQUEST['table_name'];?> table