Reply to Re: Count and Preg_Replace Using Version 4.4.1

Your name:

Reply:


Posted by Al on 12/05/05 16:19

Shaun wrote:
> Hi,
>
> The following code matches all occurences of <p> tags within an html page
> and wraps form tags around it:
>
> echo preg_replace(
> '/<p[^>]*>(.*?)<\/p>/ms',
> '<form name="form" target="_parent"
> action="'.$CFG->edit_pages_adm.'/index.php?action=edit_paragraph"
> method="post">
> <input type="hidden" name="text" value="$1">
> <p><a href="javascript:;" onclick="document.form.submit();">$1</a></p>
> </form>',
> file_get_contents($CFG->frontenddir_editable.'/'.$file) );
>
> Unfortunately if there is more than one match the form won't submit because
> the forms have the same name. Does anyone know how can I modify this so that
> each occurence is numbered sequentially i.e.
>
> form'.$count.'...
>
> As I am using version 4.4.1 I don't have access to the count paramter in
> version 5.1.
>
> Thanks for your advice


Each of your html input elements must have a different name, otherwise the php code will only see the last one.

Consider a simple foreach loop to generate your html input elements, e.g.,

$report= ""; $i= 0;

foreach($array as $key=> $value){

$report .= "<p><input type=\"text\" name=\"input$i\" value=\"\"></P>";

other stuff as needed

$i++;
}//end

echo $report;

I'm not sure I see why you need the JAVA script. Seems like you can let the user poke in everything and then provide a
submit button to post everything.

Your $_POST will contain all the results. e.g.,
$value1= $_POST['input1'];
$value2= $_POST['input2'];

etc.

Another simple foreach loop can be used to extract the input values.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация