Jump to content


JOIN is the answer I think

  • This topic is locked This topic is locked
1 reply to this topic

#1 kenwvs

  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts

Posted 09 October 2006 - 12:08 AM

I have a PHP form that I have created to store information for a work order.  I have tables called workorder, parts, images, and employees.......I also have tables to JOIN information together called workorder_parts, workorder_images and workorder_employees.  Below is the query's that I have created to put the data into the proper tables, but I am not able to figure out, as an example how to recall the information using the workorder_images table.

The queries below are all working and the data is being stored in the database tables.

Workorder Query

mysql_query("INSERT INTO workorder (work, name, sched, site, serial, hours, starts, issue, severity, resolution, assistance, safety) VALUES ('$work', '$name', '$sched', '$site', '$serial', '$hours', '$starts', '$issue', '$severity', '$resolution', '$assistance', '$safety')") or die(mysql_error());

Images Query
if ($_FILES['upload']['error'][$i] == 0)
				$uploaddir = '/home/forsa7/public_html/GE/GEUploads/';

				$uploadfile = $uploaddir . basename($_FILES['upload']['name'][$i]);
				$file_name = basename($_FILES['upload']['name'][$i]);

				if (!move_uploaded_file($_FILES['upload']['tmp_name'][$i], $uploadfile))
    				die("<br><br>File could not be uploaded.");

				// After each file is successfully uploaded, record file name in DB
				mysql_query("INSERT INTO `image` (Upload) VALUES ('$file_name')")or die(mysql_error());

I don't know how to get the auto incrementing number from the workorder and image tables into the workorder_image table.......or should I be doing it differently.

The columns in the workorder_image table are workorder_work_id and image_image_id which are both autoincrementing columns

#2 fenway

  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 09 October 2006 - 05:54 AM

You already have an identical thread here... just be patient.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users