5 Replies - 7485 Views - Last Post: 19 August 2009 - 07:57 PM Rate Topic: -----

#1 fallen0ne09  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 45
  • Joined: 13-March 09

how to send multiple data in database using form

Posted 19 August 2009 - 02:09 AM

i want to send multiple data to the database but i used select to get data from database A to database B.... i am able to send it but it only works in one by one... here is my code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php 
// Get our database connector
require("includes/conn.php");
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<table width="702" height="114" border="1">
  <tr>
	<th scope="col">&nbsp;</th>
	<th scope="col">&nbsp;</th>
  </tr>
  <tr>
	<td><?php   
								// Grab the data from our people table
								$sql = "select * from cart  ORDER BY `cart`.`id` DESC LIMIT 0, 30  ";
								$result = mysql_query($sql) or die ("Could not access DB: " . mysql_error());

								while ($row = mysql_fetch_assoc($result))
								{
										echo "<div class=\"picture\">";
										echo "<p>";
										$name = $row['name'];
								   
										  echo"<form action='senda.php' method='post'><input type='hidden' value='$name' name='name'>$name<input type='submit'></form>";
									  
  
										print("<hr>"."</hr>");
										print("<br>"."<br>"."<br>");
										echo "</p>";
										echo "</div>";
								}

						?>&nbsp;</td>
	<td>&nbsp;</td>
  </tr>
</table>
</body>
</html>

in every data shown there is a submit button, but i want only one how should i do it? is it possible? please help me i dont know what to do... and here is my other code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php 
// Get our database connector
require("includes/conn.php");
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body><?php #MySQL-Insert-Into.php
# Copyright (c) 2007 by Dr. Herong Yang, http://www.herongyang.com/
#
  
  $name = $_POST['name'];
  
  $small = $_POST['small'];
  $large = $_POST['large'];
  $meduim = $_POST['meduim'];
  $who = "Branch 1";
  $date = date("Y-m-d");
		$time = date("H:i a");

  $sql = "INSERT INTO sample (name)"
	 . " VALUES ('$name')";
   if (mysql_query($sql)) {
	print("Order Sent");
	
  } else {
	print("Sending statement failed.\n");
  
  }
  
?>
</body>
</html>

please help me... i really need it... how should i do it.... thanks

Is This A Good Question/Topic? 0
  • +

Replies To: how to send multiple data in database using form

#2 tommyflint  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 34
  • View blog
  • Posts: 679
  • Joined: 24-July 08

Re: how to send multiple data in database using form

Posted 19 August 2009 - 03:27 AM

I'm Slightly confused on what you actually want done.

Do you have one database that you get the data from and then when the user hits submit you want to save it to a second database, is this correct?

tommyflint

This post has been edited by tommyflint: 19 August 2009 - 03:28 AM

Was This Post Helpful? 0
  • +
  • -

#3 fallen0ne09  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 45
  • Joined: 13-March 09

Re: how to send multiple data in database using form

Posted 19 August 2009 - 05:28 AM

View Posttommyflint, on 19 Aug, 2009 - 02:27 AM, said:

I'm Slightly confused on what you actually want done.

Do you have one database that you get the data from and then when the user hits submit you want to save it to a second database, is this correct?

tommyflint

yup thats it... i have 2 databases in total... the database where i get the data and the database from where i want to send it... but the problem is in each data there is a submit button but i only want one... for example i have 3 names... when i hit the submit button i want all 3 to be saved in the second database all at once... thanks 4 replying....
Was This Post Helpful? 0
  • +
  • -

#4 izrafel  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 96
  • Joined: 24-July 09

Re: how to send multiple data in database using form

Posted 19 August 2009 - 06:09 AM

i cant see the point in what you are doing but if you want to copy db a in db b, just export db a open the export file and change the name of the used db (in this case db a) and change it to the name of db b.Then import and it will be 100% copy.
But then again what is the point of letting users copy stuff from one db into another and what do you want to accomplish?

This post has been edited by izrafel: 19 August 2009 - 06:12 AM

Was This Post Helpful? 0
  • +
  • -

#5 RPGonzo  Icon User is offline

  • // Note to self: hmphh .... I forgot
  • member icon

Reputation: 151
  • View blog
  • Posts: 954
  • Joined: 16-March 09

Re: how to send multiple data in database using form

Posted 19 August 2009 - 06:37 AM

Actually what it sounds like is you have a table that you pull "temporary" information from and when your ready to finalize everything you write it to your second table to hold on a more "permanent" basis ....

I think the confusion here is you keep saying 2 databases what i think you mean is 2 tables

On top of that you have all these variables being set ...

$name = $_POST['name'];
 
  $small = $_POST['small'];
  $large = $_POST['large'];
  $meduim = $_POST['meduim'];
  $who = "Branch 1";
  $date = date("Y-m-d");
		$time = date("H:i a");

  $sql = "INSERT INTO sample (name)"
	 . " VALUES ('$name')";



you set them all but then you ONLY use the $name variable ... waste of processing if your not going to use them ...

This post has been edited by RPGonzo: 19 August 2009 - 06:39 AM

Was This Post Helpful? 0
  • +
  • -

#6 fallen0ne09  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 45
  • Joined: 13-March 09

Re: how to send multiple data in database using form

Posted 19 August 2009 - 07:57 PM

sorry for all the confusions... thats right i ment 2 tables not databases... sorry...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1