Jump to content

JOIN is the answer I think


kenwvs

Recommended Posts

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

[code]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());[/code]

Images Query
[code]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());
}[/code]


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
Link to comment
Share on other sites

Guest
This topic is now 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.