Jump to content

hi all , I want to insert more than 10 record in the datea base ,


abosami

Recommended Posts

8)

 

hi all ,,

 

I have a table : test (id , name , title , area , city)

 

and I want from user to insert more than one record ..

 

I made the script but I don't know there are better than this code ..

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My test</title>
</head>
<body>
<table align="center" width="70%">
<tr>
<form action="<?php $_SERVER['PHP_SELF']?>?>" method="get">


<?php
if($_GET['submit']){
$con = mysql_connect("localhost","root","");
$db = mysql_select_db("test",$con);
for($i = 1 ; $i < 10 ; $i++){
	$name = $_GET['name'.$i];
	$title = $_GET['title'.$i];
	$area = $_GET['area'.$i];
	$city = $_GET['city'.$i];
	$sql = "INSERT INTO `test`.`test` (`title` ,`name` ,`area` ,`city`)VALUES ( '$name', '$title', '$area', '$city');";
	$query = mysql_query($sql , $con);

}
}else { 
$con = mysql_connect("localhost","root","");
$db = mysql_select_db("test",$con) or die (mysql_error());
echo '<tr><td>Name</td><td>Title</td><td>Area</td><td>City</td></tr>';
for ($i = 1 ; $i < 10 ; $i++){
echo '<tr><td><input type="text" name="title'.$i.'" /></td>
 <td><input type="text" name="name'.$i.'" /></td>
<td><input type="text" name="area'.$i.'" /></td>
<td><input type="text" name="city'.$i.'" /></td></tr>
<br />

';
}
echo '<tr><td colspan="4"><input type="submit" name="submit" value="submit" /></td></tr>';


}
?>
</form>
</tr>
</table>
</body>
</html>

 

I wait you to advise me and I want your opinion ..

 

than you very much ..

 

:D

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.