PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Wed Oct 16, 2019 3:18 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 14 posts ] 
Author Message
 Post subject: count form content
PostPosted: Sun Jan 07, 2007 10:25 pm 
Offline
Forum Newbie
User avatar

Joined: Sun Jan 07, 2007 9:58 pm
Posts: 12
Location: székelyudvarhely / erdélyország (transylvania)
hi all!
how i can count form content
or how i can simplify (optimize) this code:

Syntax: [ Download ] [ Hide ]
if (isset($_REQUEST['save_engine'])) {

  if (isset($_REQUEST['asd1'])) {save_config("asdB.php","asd1",$_REQUEST['asd1']);}

  if (isset($_REQUEST['asd2'])) {save_config("asdB.php","asd2",$_REQUEST['asd2']);}

//...

}



 echo "<form action=\"" method=post>\n";

 echo "
<input type=text name=\"asd1\" value=\"".read_config("asd.php","asd1")."\"\n";  

 echo "<input type=text name=\"asd2\" value=\"".read_config("asd.php","asd2")."\"\n";  

//...

 echo "<input type=submit name=save_engine></form><td></tr>\n";


Last edited by eaposztrof on Sun Jan 07, 2007 11:59 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 07, 2007 10:33 pm 
Offline
DevNet Evangelist
User avatar

Joined: Tue May 07, 2002 9:48 am
Posts: 8391
Location: Berlin, ger


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 07, 2007 11:54 pm 
Offline
Forum Newbie
User avatar

Joined: Sun Jan 07, 2007 9:58 pm
Posts: 12
Location: székelyudvarhely / erdélyország (transylvania)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 08, 2007 12:06 am 
Offline
Forum Contributor
User avatar

Joined: Wed Dec 06, 2006 10:33 am
Posts: 454
Location: Picnic Garden, Kolkata, India


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 08, 2007 12:45 am 
Offline
DevNet Evangelist
User avatar

Joined: Tue May 07, 2002 9:48 am
Posts: 8391
Location: Berlin, ger
try
Syntax: [ Download ] [ Hide ]
<?php

function read_config($a,$b) {

        return 'val_'.$b;

}



function save_config($a,$b,$c) {

        echo "<div>save_config($a,$b,$c)</div>\n";

}

?>

<html>

        <head><title>php/html array</title></head>

        <body>

<?php  

if ( isset($_POST['asd']) && is_array($_POST['asd']) ) {

        foreach($_POST['asd'] as $key=>$value) {

                save_config('asdB.php', $key, $value);

        }

}

?>

                <form action="#" method="post">

                        <div>

                        <?php for ($i=0, $z=rand(10,15); $i<$z; $i++) { ?>

                                <input type="text" name="asd[asd<?php echo $i; ?>]" value="<?php echo read_config('asd.php', 'asd'.$i); ?>" />

                                <br />

                        <?php } ?>

                                <input type="submit" />

                        </div>

                </form>

        </body>

</html>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 08, 2007 12:49 am 
Offline
Forum Newbie
User avatar

Joined: Sun Jan 07, 2007 9:58 pm
Posts: 12
Location: székelyudvarhely / erdélyország (transylvania)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 08, 2007 12:54 am 
Offline
Forum Contributor
User avatar

Joined: Wed Dec 06, 2006 10:33 am
Posts: 454
Location: Picnic Garden, Kolkata, India
1 moment
are you trying to generate/Write php codes on the fly/WhileRunning and compile it on the fly and then show it ??


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 08, 2007 1:13 am 
Offline
Forum Newbie
User avatar

Joined: Sun Jan 07, 2007 9:58 pm
Posts: 12
Location: székelyudvarhely / erdélyország (transylvania)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 08, 2007 1:49 am 
Offline
Forum Newbie
User avatar

Joined: Sun Jan 07, 2007 9:58 pm
Posts: 12
Location: székelyudvarhely / erdélyország (transylvania)
how i can put in array the name's and value's of inputs in the form? the form is static!
Syntax: [ Download ] [ Hide ]
echo "<form action=\"" method=post>\n";

 echo "
<input type=text name=\"asd1\" value=\"asd1_value\"";

 echo "<input type=text name=\"asd2\" value=\"asd2_value\"";  

...


Last edited by eaposztrof on Mon Jan 08, 2007 4:37 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 08, 2007 10:04 am 
Offline
Neighborhood Spidermoddy
User avatar

Joined: Mon Mar 29, 2004 4:24 pm
Posts: 31559
Location: Bothell, Washington, USA
eaposztrof, we're not asking for much. Just use the proper tags.
Syntax: [ Download ] [ Hide ]
should only be used if you cannot find the most suitable tag. We have many to choose from.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 08, 2007 11:59 am 
Offline
DevNet Evangelist
User avatar

Joined: Tue May 07, 2002 9:48 am
Posts: 8391
Location: Berlin, ger


Top
 Profile  
 
 Post subject: sajnos
PostPosted: Mon Jan 08, 2007 5:43 pm 
Offline
Forum Newbie
User avatar

Joined: Sun Jan 07, 2007 9:58 pm
Posts: 12
Location: székelyudvarhely / erdélyország (transylvania)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 08, 2007 11:31 pm 
Offline
Forum Newbie
User avatar

Joined: Sun Jan 07, 2007 9:58 pm
Posts: 12
Location: székelyudvarhely / erdélyország (transylvania)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 09, 2007 12:52 am 
Offline
DevNet Resident
User avatar

Joined: Tue Aug 13, 2002 5:10 pm
Posts: 1040
Location: Back in Phoenix, missing the microbrews
I'm not sure if this is what you're looking for...
Syntax: [ Download ] [ Hide ]
${'text_cpanel_' . $i}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group