Jump to content

Recommended Posts

hi i am new to php and i am working on a form which has to generate a table row on the button click , but my problem is that i don't have any idea to how do i save that incremented textbox value in my databasa . Can anyone help me out please it would be a huge favor. i have attached my my php script and html script along with this message

here is my code

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[url="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd%22>"]http://www.w3.org/TR...nsitional.dtd">[/url]
<html xmlns="[url="http://www.w3.org/1999/xhtml%22>"]http://www.w3.org/1999/xhtml">[/url]
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>Makhtab</title>
		<link rel="stylesheet" type="text/css" href="form2/view.css" media="all">
			<script type="text/javascript" src="form2/view.js"></script>
			<script type="text/javascript" src="form2/calendar.js"></script>
			<meta http-equiv="Content-Script-Type" content="text/javascript">
				<script type="text/javascript">

						function deleteRow(row)
						{
						var i=row.parentNode.parentNode.rowIndex;
						document.getElementById('POITable').deleteRow(i);
						}


						function insRow()
						{
						console.log( 'hi');
						var x=document.getElementById('POITable');
						var new_row = x.rows[1].cloneNode(true);
						var len = x.rows.length;
						new_row.cells[0].innerHTML = len;

						var inp1 = new_row.cells[1].getElementsByTagName('input')[0];
						inp1.id += len;
						inp1.value = '';
						var inp2 = new_row.cells[2].getElementsByTagName('input')[0];
						inp2.id += len;
						inp2.value = '';
						x.appendChild( new_row );
						}
			</script>
						  <script type="text/javascript">

						function deletezimRow(row)
						{
						var i=row.parentNode.parentNode.rowIndex;
						document.getElementById('zimtable').deleteRow(i);
						}


						function inszimRow()
						{
						console.log( 'hi');
						var x=document.getElementById('zimtable');
						var new_row = x.rows[1].cloneNode(true);
						var len = x.rows.length;
						new_row.cells[0].innerHTML = len;

						var inp1 = new_row.cells[1].getElementsByTagName('input')[0];
						inp1.id += len;
						inp1.value = '';
						var inp2 = new_row.cells[2].getElementsByTagName('input')[0];
						inp2.id += len;
						inp2.value = '';
						x.appendChild( new_row );
						}
			</script>
								<!--<style type="text/css" title="currentStyle">
									@import "tran/css/layout-styles.css";
									@import "tran/css/themes/smoothness/jquery-ui-1.8.4.custom.css";
								</style>-->
			<script  type="text/javascript" src="tran/js/jquery-1.6.1.min.js"></script>
			<script  type="text/javascript" src="tran/js/jquery-ui-1.8.14.custom.min.js"></script>

			<script  type="text/javascript" src="tran/js/jq-ac-script.js"></script>
			</head>
			<body id="main_body" >

				<img id="top" src="form2/top.png" alt="">
					<div id="form_container">

						<h1><a>Untitled Form</a></h1>
						<form id="makhtab" class="appnitro" enctype="multipart/form-data" method="post" action="makhproc.php">
							<div class="form_description">
								<h2>Makhtab Details</h2>
								<!--<p>This is your form description. Click here to edit.</p>-->
							</div>
							  <table border="0px" width="100%">
								<tr>
									<td><label class="description" for="element_1">Code</label></td><td><input id="element_1" name="code" class="element text small" type="text" maxlength="6" value=""/></td>
								</tr>
								<tr>
									<td><label class="description" for="element_1">Name</label></td><td><input id="element_1" name="name" class="element text large" type="text" maxlength="40" value=""/> </td>
								</tr>

								<tr>
									<td><label class="description" for="element_1">Address</label></td><td><input id="element_4_1" name="add1" class="element text large" value="" type="text"></td>
								</tr>
								<tr>
									<td></td><td><input id="element_4_1" name="add2" class="element text large" value="" type="text"></td>
								</tr>
								<tr>
									<td></td><td><input id="element_4_1" name="add3" class="element text large" value="" type="text"></td>
								</tr>
								<tr>
									<td><label class="description" for="element_1">City</label></td><td><select name="cmbcity" class="element text medium" style="font-size:18px;"/>
										<option value=""></option>
										<?php
										mysql_connect("localhost", "root", '') or die(mysql_error());
										mysql_select_db("webapp") or die(mysql_error());
										$result = mysql_query("SELECT `name` from city ") or die(mysql_error());

										while ($year = mysql_fetch_array($result)) {

											echo "<option value='$year[name]'>$year[name]</option>";
										}
										?>
					</select>

								</tr>
																	<tr>
									<td><label class="description" for="element_1">State</label></td><td><select name="cmbstate" class="element text medium" style="font-size:18px;"/>
										<option value=""></option>
										<?php
										mysql_connect("localhost", "root", '') or die(mysql_error());
										mysql_select_db("webapp") or die(mysql_error());
										$result = mysql_query("SELECT `name` from state ") or die(mysql_error());

										while ($year = mysql_fetch_array($result)) {

											echo "<option value='$year[name]'>$year[name]</option>";
										}
										?>
					</select>
																	</tr>
							</tr>
							<tr>
								<td><label class="description" for="element_1">Country</label></td><td><select name="cmbcountry" class="element text medium" style="font-size:18px;"/>
									<option value=""></option>
									<?php
									mysql_connect("localhost", "root", '') or die(mysql_error());
									mysql_select_db("webapp") or die(mysql_error());
									$result = mysql_query("SELECT `name` from country ") or die(mysql_error());

									while ($year = mysql_fetch_array($result)) {

										echo "<option value='$year[name]'>$year[name]</option>";
									}
									?>
									</select>
								<tr>
									<td><label class="description" for="element_1">Telephone</label></td><td><input id="element_1" name="country" class="element text medium" type="text" maxlength="255" value=""/></td>
								</tr>
								<tr>
									<td><label class="description" for="element_1">Mobile</label></td><td><input id="element_1" name="country" class="element text medium" type="text" maxlength="10" value=""/></td>
								</tr>
								<tr>
									<br />
								</tr>

								</table>

									 <tr>
								<br /><p style="border-bottom: 1px dotted #ccc;"></p><br />
								<div class="form_description">
									<h2>Zimmedar Details</h2>
									<!--<p>This is your form description. Click here to edit.</p>-->
								</div>
							</tr>
									 <input type="button" id="addmorezimbutton" value="Add zimmedar" onclick="insRow()"/><br/><br/>
								<table id="zimtable" border="0px" size="100px" cellspacing="0" cellpadding="2">
									<tr>
										<td width="10" align="center"><label class="description">Srno. </label></td>
										<td width="118"><label class="description">Zimmedar Name</label></td>
										<td width="118"><label class="description">Mobile</label></td>

										<td width="10"></td>
										<td width="10" align="center"></td>
									</tr>
									<tr>
										<td>1</td>
										<td width="210"><input  size="40" maxlenght="40" type="text" id="zimame[]"/></td>
										<td width="80"><input  size="10" maxlenght="10" type="text" id="zimmob[]"/></td>

										<!--<td><input  size="45" maxlenght="10" type="text" id="momob"/> </td>-->
										<td><input type="button" id="addzimmore" value="+" onclick="inszimRow()"/></td>
										<td align="center"><input type="button" id="delzimbutton" value="-" onclick="deletezimRow(this)"/></td>
									</tr>

								</table>

																	 <tr>
								<br /><p style="border-bottom: 1px dotted #ccc;"></p><br />
								<div class="form_description">
									<h2>Muallim Details</h2>
									<!--<p>This is your form description. Click here to edit.</p>-->
								</div>
							</tr>
									 <input type="button" id="addmorePOIbutton" value="Add Muallims" onclick="insRow()"/><br/><br/>
									<table id="POITable" border="0px" size="100px" cellspacing="0" cellpadding="2">
										<tr>
											<td width="10" align="center"><label class="description">Srno. </label></td>
											<td width="118"><label class="description">Moallim Name</label></td>
											<td width="118"><label class="description">Mobile</label></td>
											<td width="118"><label class="description">Qabiliyat</label></td>
											<td width="10"></td>
											<td width="10" align="center"></td>
										</tr>
										<tr>
											<td>1</td>
											<td width="210"><input  size="40" maxlenght="40" type="text" id="moname[]"/></td>
											<td width="80"><input  size="10" maxlenght="10" type="text" id="momob[]"/></td>
											<td><select name="cmbmuallim[]" class="element text large" style="font-size:18px;"/>
												<option value=""></option>
												<?php
												mysql_connect("localhost", "root", '') or die(mysql_error());
												mysql_select_db("webapp") or die(mysql_error());
												$result = mysql_query("SELECT `name` from qabiliyat ") or die(mysql_error());

												while ($year = mysql_fetch_array($result)) {

													echo "<option value='$year[name]'>$year[name]</option>";
												}
												?>
												</select></td>
											<!--<td><input  size="45" maxlenght="10" type="text" id="momob"/> </td>-->
											<td><input type="button" id="addmore" value="+" onclick="insRow()"/></td>
											<td align="center"><input type="button" id="delPOIbutton" value="-" onclick="deleteRow(this)"/></td>
									</tr>
								</table>

										 <br /><p style="border-bottom: 1px dotted #ccc;"></p><br />
										 <table border="0px" width="85%">
											 <tbody><tr>
													 <td width="105"><label class="description">No. of Students</label></td>
													 <td width="65"><input type="text" name=stu" size="5" maxlength="5"></input></td>
													 <td width="105"><label class="description">No. of Batches</label></td><td width="14"><input type="text" name="batch" size="5" maxlength="3"></input></td>
												 </tr>
												 <tr>
													 <input type="submit" name="submit" value="Save"></input>

												 </tr>
											 </tbody>



										 </table>	
								</div>
								</div>
						</table>



						</form>  

						</body>
						</html>

makhtab.php

makhproc.php

<snip removed 100's of lines of quoted post>

 

Why you are again and again connecting to database and generating it.

 

Use it once at top of page. For generating table you can echo tr like this echo "<tr><td>"

Edited by PFMaBiSmAd
removed quoted information
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.