Jump to content


Photo

Lets see who is the Guru Of All The Gurus


  • Please log in to reply
3 replies to this topic

#1 ankycooper

ankycooper
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 23 September 2006 - 09:41 PM

hi
i have a form with fields name age gender email.
i want to insert multiple records into a dataase with 1 form

Need some help
Good informative links are welcome

This is my script and i'm trying to insert mutiple data rows with 1 form
<?php
session_start();

if (!isset($_SESSION['logged_in']) || $_SESSION['logged_in'] !== true || !isset($_SESSION['role']) || $_SESSION['role'] !=="Manager") {
	// not logged in, move to login page
	header('Location: ../login.php');
	exit;
}
include '../config/dbinfo.inc.php';
@mysql_connect($host,$user_name,$pass_word)or die( "Unable to Connect to database");
@mysql_select_db($database) or die( "Unable to select database");

$specialty=$_GET['specialty'];
$mmyy=$_GET['mmyy'];

 $query = "SELECT * FROM emp WHERE specialty = '$specialty' and role='Engineer' or specialty = '$specialty' and role='TL-ATL' order by mgr";
 $result = mysql_query($query) or die('Error : ' . mysql_error());
		
if (isset($_POST['sdate*']) && isset($_POST['edate*']) && isset($_POST['now*'])){

function dateconvert($date,$func) {
		if ($func == 1){ //insert conversion
			list($day, $month, $year) = split('[/.-]', $date); 
			$date = "$year-$month-$day"; 
			return $date;
		}
		if ($func == 2){ //output conversion
			list($year, $month, $day) = split('[-.]', $date); 
			$date = "$day/$month/$year"; 
			return $date;
		}
}

$specialty=$_GET['specialty'];
$mmyy=$_GET['mmyy'];
$sdate=$_POST['sdate*'];
$sdate=dateconvert($sdate, 1);
$edate=$_POST['edate*'];
$edate=dateconvert($edate, 1);
$now=$_POST['now*'];


while(list($id) = mysq


#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 23 September 2006 - 09:58 PM

What do you need help with?

What doesn't work with the code you have already written?

If you're looking for a 'how do I add information to a database', take a look at the tutorials linked from the home page of phpfreaks.com

Understand the the object of 'help' is help, not 'what can we write for you'  ;D
Legend has it that reading the manual never killed anyone.
My site

#3 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 23 September 2006 - 10:56 PM

Like all moderators and admins, I would prefer that you not email me personally about this.

For those interested, the other half of this problem is the code you'll find at http://www.halfadot....temp/script.txt
Legend has it that reading the manual never killed anyone.
My site

#4 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,022 posts

Posted 23 September 2006 - 11:34 PM

Similar problem with solution here

http://www.phpfreaks....html#msg439902
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users