
June 16th, 2004, 11:11 AM
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
Creating SQL table via PHP
Hi friends,
I am having this problem which I am unable to solve.
I am trying to create a user friendly inventory database.
To create a table, the user enters the number of fields required.
The user clicks submit and (using a form) and is redirected to another page where there are (#of fields)textboxes displayed using a for loop. The user is supposed to type in the required fields and then click submit. It should then output the all the fields. My problem is that how can I access those text fields if I have used a for loop to create them. I know that if I normally give a text box a variable name.. I can then POST it. But here it's in a for loop that get repeated as many times depending on the number of fields selected by the user. Please help..I am trying to figure this out..and am still unsuccessful. Here is the part of the code causing all the problem:
PHP Code:
function create_table(){
global $_REQUEST;
$out.= "<H2><B>Create Table</B></H2>";
$out.= "<form action = '?res=tblinfo' method = 'post'>
Table Name: <input type = 'text' name = 'tablename'/>
Enter Fields: <input type = 'text' name = 'fields'/>
<input type = 'submit' name = 'submit' value = 'Submit table' />
</form>";
return $out;
}
function table_info(){
$out = "<H4><b>{$_POST['tablename']}<b></H4>";
$out.= "<H4><b>Enter Required Fields<b><H4>";
$out.= "<form action = '?res=query' method = 'post'>";
for($i=1; $i<=$_POST['fields']; $i++){
$out.= "<input type = 'text' name = 'field'/><br>";
}
$out.= "<input type = 'submit' name = 'submit' value = 'Submit' />
</form>";
return $out;
Last edited by stumpy : June 18th, 2004 at 01:58 AM.
Reason: Please use helpful thread titles, and wrap your code in code tags
|