WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Dynamic generation of textboxes, select items etc in a table for use with databases applications, matrimonials and for job sites
Categories : PHP, HTML and PHP, Java Script Click here to Update Your Picture
saji nair
Date : Aug 01st 2005
Grade : 3 of 5 (graded 5 times)
Viewed : 10492
File : 4207.php
Images : No Images for this code example.
Search : More code by saji nair
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

table.php
<script language="javascript" type="text/javascript">
function add(count){
    var temp="";
    temp=temp+"<table width='740' align='center' border=0>"
    temp=temp+"<tr><td></td><td style='border-style:none' align='left'>"
    temp=temp+"<input type='text' name=row1"+count+" size='20' maxlength='100'>"//row2
    temp=temp+"</td>"
    temp=temp+"<td style=border-style:none align='right'>"
    temp=temp+"<input type=text name=row2"+count+" size='10' maxlength='10'>"//row12
    temp=temp+"</td>"
    temp=temp+"<td style=border-style:none align='right'>"
    temp=temp+"<input type=text name=row3"+count+" size='10' maxlength='10'>"//row22
    temp=temp+"</td><td style=border-style:none align='left'><a href='javascript:add("+(++count)+")'>+</a></td></tr>"
    temp=temp+"</table>"
    //alert(document.getElementById("divisions"));
    document.all("divisions").innerHTML=document.all("divisions").innerHTML+temp;

}

</script>

<?php

print"<html><body>";                                                    ////creating html and body tags
print "<form name='frm1' action='count.php' method='post'>";        ///creating form for posting
$count=1;                                                                //a counter to increment the rows
print "<div id='divisions'>";                                            ///creating division where the rows will be inserted
print "<table border=0 border-style='ridge' width=750 align='center'>";        /// first table
print "<tr><td></td></tr>";
print
"<tr><td></td><td style=border-style:none align='left'>";
print
"<input type='text' name=row1".$count." size='20' maxlength='100'>";//row11  creating first row with the names as row
print "</td>";
print
"<td style=border-style:none align='right'>";
print
"<input type=text name=row2".$count." size='10' maxlength='10'>";//row21
print "</td>";
print
"<td style=border-style:none align='right'>";
print
"<input type=text name=row3".$count." size='10' maxlength='10'>";//row31
print "</td><td style=border-style:none align='left'><a href='javascript:add(".++$count.")'>+</a></td></tr>"; /// hyperlink and counter to add rows using javascript
print "</table>";                                                        ///end of first table
print "</div>";                                                            //// division gets over                                   
print "<table border=0 width=740 align='center'><tr><td colspan=5 align='center'><input type='submit'></td></tr></table>";        // table & submit buttonthird table end
print "</form>";                    //end of form
print"</body></html>";                //end of html and body
?>



count.php
<?php
foreach ($_POST as $key=>$value) {
    print
"$key = $value<br>";
}
?>



Pull Down Surfing - Surf on Change
Categories : Java Script, MySQL, HTML and PHP, PHP, Databases
Remote Scripting: send form POST data to a script and insert the results into a page without refreshing the page.
Categories : PHP, AJAX, HTML and PHP, Java Script
Tree Menu Dynamic (+Static) with Loading in Progress..
Categories : PHP, Java Script, HTML and PHP
OverEasy - PHP generated JavaScript to do mouseovers on your pages. Modify one file and one function does it all for you!
Categories : PHP, Java Script, HTML and PHP, MySQL
This PHP function creates dropdown select lists for time and date that you can change, outputs a 14 char MySQL timestamp in a text field
Categories : PHP, MySQL, Java Script, HTML and PHP
Function that allows a Javascript cookie to be set after HTML has been outputted to the page.
Categories : PHP, Java Script, Cookies, HTML and PHP
Local-to-user date and time display regardless of time zone or where the website's server is located
Categories : PHP, Date Time, HTML and PHP, Java Script
PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use!
Categories : HTML and PHP, Email, PHP, Perl, HTML and PHP
Newbie Notes #9 - Hyperlinking a post
Categories : PHP, Java Script, HTML and PHP, Beginner Guides
PHP4 session helper HTML file.
Categories : PHP, Java Script, HTML and PHP, Sessions
Dynamic Calender in PHP, Javascript and HTML.
Categories : PHP, Java Script, HTML and PHP, Calendar
Validator 98 - a PHP-script to generate form-validation-code in JavaScript.
Categories : Complete Programs, Java Script, PHP, HTML and PHP
a function that builds an HTML select list from any mysql table.
Categories : PHP, MySQL, HTML and PHP
Message of the Day - Random Message (Needs MySQL!)
Categories : Databases, HTML and PHP, PHP, MySQL
Alternating background color for HTML table rows
Categories : PHP, Databases, MySQL, HTML and PHP
 matthew waygood wrote :1340
Nice little bit of script, but thought it a bit stange you printed the first form when you have the javascript there to do it for you. Also no need for the PHP bit, as you can use javascript to hold the count.
Heres the re-write for you:-

&lt;script language="javascript" type="text/javascript"&gt;
count=1;
function add(count){ 
    var temp=""; 
    temp=temp+"&lt;table width=`740` align=`center` border=0&gt;" 
    temp=temp+"&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td style=`border-style:none` align=`left`&gt;" 
    temp=temp+"&lt;input type=`text` name=row1"+count+" size=`20` maxlength=`100`&gt;"//row2 
    temp=temp+"&lt;/td&gt;" 
    temp=temp+"&lt;td style=border-style:none align=`right`&gt;" 
    temp=temp+"&lt;input type=text name=row2"+count+" size=`10` maxlength=`10`&gt;"//row12 
    temp=temp+"&lt;/td&gt;" 
    temp=temp+"&lt;td style=border-style:none align=`right`&gt;" 
    temp=temp+"&lt;input type=text name=row3"+count+" size=`10` maxlength=`10`&gt;"//row22 
    temp=temp+"&lt;/td&gt;&lt;td style=border-style:none align=`left`&gt;&lt;a href=`javascript:add("+(++count)+")`&gt;+&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;" 
    temp=temp+"&lt;/table&gt;" 
    //alert(document.getElementById("divisions")); 
    document.all("divisions").innerHTML=document.all("divisions").innerHTML+temp; 


&lt;/script&gt; 
&lt;html&gt;
  &lt;body&gt;
    &lt;form name=`frm1` action=`count.php` method=`post`&gt;
      &lt;div id=`divisions`&gt;
        &lt;script language="javascript" type="text/javascript"&gt;
          add(count);
        &lt;/script&gt; 
      &lt;/div&gt;
      &lt;input type="submit" value="submit"/&gt;
    &lt;/form&gt;
  &lt;/body&gt;
&lt;/html&gt;