php - Add list item every time i click submit -


i want script echo text form div tag every time click submit button.

i able in no time want text still displayed in div when submit another. want every new submitted text create list. adding previous list.

may got database know every time click submit current text been submitted.

example of such script

<?php  $text = $_post['text'];  ?> <html> <div> <?php echo "<ul>"; echo "<li>".$text."</li>"; echo "</ul>"; ?> </div>  <form method="post" action="<?php echo $_server['php_self'];?>"> name: <input type="text" name="text" /><br/> <input type="submit" value="submit"/> </form>  </html> 

i want adding entries <li> list every time click submit.

i'm happy you're having fun. here's quick "starter 10" :)

<?php $items = array(); if('post' === $_server['request_method']) {     if( ! empty($_post['item'])) {         $items[] = $_post['item'];     }     if(isset($_post['items']) && is_array($_post['items'])) {         foreach($_post['items'] $item) {             $items[] = $item;         }     } } ?> <html>     <head>         <title>demo</title>     </head>     <body>         <?php if($items): ?>             <ul>                 <?php foreach($items $item): ?>                     <li><?php echo $item; ?></li>                 <?php endforeach; ?>             </ul>         <?php endif; ?>         <form method="post">             <input type="text" name="item" />             <input type="submit" value="add item" />             <?php if($items): ?>                 <?php foreach($items $item): ?>                     <input type="hidden" name="items[]" value="<?php echo $item; ?>" />                 <?php endforeach; ?>             <?php endif; ?>         </form>     </body> </html> 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -