Please help me???

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
szms
Forum Contributor
Posts: 101
Joined: Thu Jun 26, 2003 12:23 pm

Please help me???

Post by szms »

I want to execute the following menu as many times as the user want. Please take a look and give me some suggestion.
First the user will be asked the number of time he/she wants to execute the menu bar in the same page (without opening a new page).

Please help me???

<form action="InsertFunctionComponent.php" method="GET">


<br><br><b>How many times you want</b>
<input type="text" name="number" Size = "30">
<br><br>
<?php
if($submit)
{
?>
<br>Select any of the following Function<br><br>
<select name = "FunctionMenu" Multiple>
<?php
foreach ($Function_Name as $Existing_Function)
print " <option value=\"$Existing_Function \">$Existing_Function</option>";
?>
</select>
<input type="submit" value="Submit" name="submit">
<input type="reset" value="Reset" name="Reset">

</form>
<?php
}

else
{
---do something---
}
?>

:?:
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Not sure i followed, but something similiar? Play around with it.

Code: Select all

<?php
$Function_Name[] = "foo";
$Function_Name[] = "bar";
$Function_Name[] = "foobar";
$Function_Name[] = "barfoo";
$Function_Name[] = "kittythrow";
?>
<pre>
<form method="POST"> 
<b>How many times you want</b> 
<input type="text" name="number" Size = "30"> 
<?php 
    if(isset($_POST['submit'])) { 
?> 
<b>Select any of the following Function</b>
<?php 
        for ($i=0; $i<$_POST['number']; $i++) {
            echo '<select name="FunctionMenu'.$i.'">';
            foreach ($Function_Name as $Existing_Function) {
                echo "<option value="$Existing_Function ">$Existing_Function</option>"; 
            }
            echo "</select>\n";
        }
    }
?>
<input type="submit" value="Submit" name="submit"> 
<input type="reset" value="Reset" name="Reset"> 
</form>
<?php 
    if(isset($_POST['FunctionMenu'])) { 
        echo 'You choosed '.$_POST['FunctionMenu'].'!';
    }
?>
szms
Forum Contributor
Posts: 101
Joined: Thu Jun 26, 2003 12:23 pm

Post by szms »

Thank you for your reply. I think you are very close but still I have some question for you. I do not want to show the all menu after pressing the first submit button. I mean suppose user chose the # 3. So after hitting submit button it will be shown the first menu then user will chose some any item from it and then hit the submit button. This seleceted item will be stored in a MYSQL database. then the second menu and at last the 3rd menu will be shown and the user will choose items from those two menus respectively. Hopefully you understood my problem. Thank you.

First of all user will be asked how many time? suppose 'n' times.

Then user can select one item from a menu. then hit Submit button. Data will be stored. Then it will show the menu again and user will select one. this process will be executed n times.

How to do this in one single page (without opening another page)

Hopefully make sense this time !!!
szms
Forum Contributor
Posts: 101
Joined: Thu Jun 26, 2003 12:23 pm

Post by szms »

I tried the following code but in am getting the menus all at a time but I am looking for one at a time and thenext one will be appeared after hitting the submit button. Waiting for some suggestions.

Code: Select all

<?php 
if($submit != "submit" || $submit != "send")
&#123;
print "<form action="index.php" method="GET">";
print "<p>Enter in the number of times below:</p>";
print "<input type="text" name="number" size="30">";

print "<input name="submit" type="submit" value="send">";
print "<input name="reset" type="reset" value="reset">";
print "</form>";
&#125;
if ($submit == "send")
&#123;

$main_count = 1;
$months = array("January","February","March","April","May","June","July",
                    "August","September","October","November","December");
$number = $HTTP_GET_VARS&#1111;"number"];                    
print "<form action="index.php" method="GET">";
while($main_count <= $number)
&#123;
print "<select name="something" value="$main_count" multiple";
    for ($x_f=0; $x_f<=count($months); $x_f++)
    &#123;
        print "\t<option value="$x_f">".$months&#1111;$x_f-1]."\n";
        reset($months);
    &#125;
    print "</select>";
    print "<br>";
$main_count++;
&#125;
print "<input name="submit" type="submit" value="submit">";
print "<input name="reset" type="reset" value="reset">";
print "</form>";
&#125;
if ($submit == "submit")
&#123;
//you insert all of the data from the form element into the DB here
//make sure to use $HTTP_GET_VARS&#1111;""]; for you variables
    print "Hello World";
&#125;
?>
Post Reply