Jump to content

kenwvs

Members
  • Posts

    194
  • Joined

  • Last visited

    Never

Everything posted by kenwvs

  1. There was another pop up blocker working overtime to stop the pages from loading. I have this working properly again. Thanks for any thoughts on this.
  2. I am not sure this is the right place to ask this, but I will try I am using IE 7 and have been for a while now. Recently it has started acting strange in that if I try to open a link, and it is suppose to open in a new tab, sometimes it will open, but usually it wont work at all. If I right click and select open in new tab, most of the time it works, but again, sometimes it won't work unless i copy and paste the code into the explorer bar. I wasn't sure if it was IE or my computer, and I used firefox and it all works fine, didn't have any problems. Any ideas would be greatly appreciated. Ken
  3. I am not understanding how to get the auto-increment value.  As there could be 4 images (or seven parts), if I use the mysql_insert_id(); I will only get the last number, and be missing the ones generated earlier in the same query
  4. 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
  5. I have tried using the last script supplied, but for some reason it isn't sending an email.  I have also added the line [code=php:0]echo 'Email has been sent to'.$_POST[$ename];[/code] to see what it shows and it prints out the Email has been sent to, but there is no names in there. Am I missing a step as far as setting the email address of something for it to use it?  I am not really sure what I would need to change to make this actually send the email.  the rest of the form is being saved to the Db, so it is making a connection and not generating any errors. Any ideas or suggestions would be appreciated.  Would I need to save the names to a db table before it could send the email? Thanks, Ken
  6. Ok, I see what you are saying.  Thanks a bunch for the help.  It is starting to make sense now.  I appreciate your help. Ken
  7. I am sorry, but I am not following what you have just said. Ken
  8. I will try that.  I have no idea how to do this, as I am new at all of this.  I have never used the mail function, and this is the first DB project I have ever worked on.
  9. The dropdown box has a list of names (not email addresses) that it has gotten from the employee table of the database.  Once you select which names you want to send an email to, I need to get the email addresses from the employee table, to actually send the email.
  10. If I use an array and do this, I will end up with something like this.......... [code]<div>                                         <center><B>Send this form to:</B><BR>                                         <select name='emailname[]' multiple="multiple">                                         <?php     $result = mysql_query("SELECT * FROM employees") or die(mysql_error());     while ($row = mysql_fetch_assoc($result)) {         echo "<option>$row[name]</option>";     } $emailname=$_POST['emailname']; if ($emailname){ foreach ($emailname as $ename); }     ?></select></center>[/code] Would I then be able to do something like this to get the email addresses into the TO field of the email script: SELECT email from employees where $ename=name; email is the column name in the DB table and name is the column title where the name is found. Thanks, Ken
  11. I have developed a form that employees will fill out and then the results are saved in the mysql database.  I have a table called workorder, which stores most of the results.  I also have a table called parts, where the parts required are stored and an image table, where the images for this workorder are saved. I also have a workorder_image and workorder_parts table, to tie everything together.  I am not sure how to get the information into the JOIN tables.  The workorder, image and parts table all use a unique key, auto incrementing and I thought it would be these numbers that would tie it all together.  There could be up to 4 rows of images and 7 rows of parts for each workorder.  If I am trying to tie the images to the workorder table, would I be better off using the workorder number (which is the Month, Hour, Second format) and the image number, to tie them together? I hope this makes sense.......it is driving me crazy.  I had it all setup using one table and was advised this was bad as far as database normalization is concerned, so I have changed things around, but have gotten in over my head.  This is my first project using a database. Here is the queries I am using right now. [code]{   if (!empty($val))   {   $query = "INSERT IGNORE INTO parts (description,number) VALUES ('" . $description[$key] . "', '" . $val . "')"; mysql_query($query) or die(mysql_error().$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()); //mysql_query("INSERT INTO workorder_parts (number, workorder_work_id) VALUES ('number[]', 'last_insert_id')")or die(mysql_error()); mysql_query("INSERT INTO workorder_image(image_image_id,workorder_work_id) VALUES ('$image_id', 'last_insert_id()')")or die(mysql_error()); } }[/code] this next one is for the images [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] Thanks, Ken
  12. I have a form that gets completed and then I want to email the results of the form to different people.  The person completing the form will choose who they want to send the results to.  I have a dropdown box, where the list of names used is obtained from the database. Is there a way, that when a person hilites multiple names that the email can be sent to these people. Here is what I have for the dropdown box. [CODE]<div>                                         <center><B>Send this form to:</B><BR>                                         <select name='tech' multiple>                                         <?php     $result = mysql_query("SELECT * FROM employees") or die(mysql_error());     while ($row = mysql_fetch_assoc($result)) {         echo "<option>$row[name]</option>";     }[/CODE] Once you have selected who the email goes to, and completed the form, I want to create a query that will send the email to these people when you press the submit button for the rest of the form.  The data is being saved in a database, but I don't have it set up to save the names of the people receiving an email (although I could if necessary.) Thanks for any help as this has me totally stumped. Ken
  13. Check with your host as to whether they allow CHMOD777.  My host (LunarPages) does not allow you to set your permissions to this.  I have been told by them to use 755 for folders and 644 for files.  Try these and see what happens.
  14. kenwvs

    Left Join

    I have gone through the database normalization process, and rewrote the queries in php to accomodate this, but now, in preparation for the next step, where the data can be retrieved, I need some help in understanding the LEFT JOIN. I had been advised that in the many=>many format, I should create a third table, but am now wondering if that was ONLY if my host supported INNODB table types. I have one table called workorder, where the basic information goes, and a second table where the part number and description of the parts required will go. The WorkOrder table has the following columns - work_id(primary key, auto-increment), work(work order number (in mmhhddss format), name, site, serial, severity, issue and sched(date) The Parts table has parts_id(primary key, autoincrement), number, description.  Do I need to add another column to the Parts Table that would have a field that is the same as the workorder table?  Perhaps the workorder # or use the primary key through the use of the mysql_insert_id().  Any direction on this would be appreciated. Ken
  15. Sorry to intrude here. What do you mean by escape everything being inserted into the database, and why do we do this?
  16. That did solve the problem.  I actually thought the descriptions were ok as it is part number and part description.
  17. so, if I understand correctly, if I remove those two arrays, it will post the proper data.  But I was trying it without them, and it would still post empty rows.  Am I missing something to get it to not post the empty lines
  18. I have a form that has seven fields for part numbers and seven fields for descriptions.  In some cases all seven fields will be filled in, and in other cases, some of the fields will be empty.  I need to create some code so that if the part number and description fields are empty, they get ignored.  In the end, I don't want empty rows being added to the database table. here is what I have, and it is putting seven rows in the database.  It is also not putting the form field data in the DB.  In the number field it is just putting a zero and in the description field it is putting description[] Here is what I have, and I would appreciate any help in putting together some code to eliminate the empty fields from posting. This is the form fields: [code]<input type="text" size="10" maxlength="10" name="number[]"> <input type="text" size="93" maxlength="93" name="description[]"><BR> <input type="text" size="10" maxlength="10" name="number[]"> <input type="text" size="93" maxlength="93" name="description[]"><BR> <input type="text" size="10" maxlength="10" name="number[]"> <input type="text" size="93" maxlength="93" name="description[]"><BR> <input type="text" size="10" maxlength="10" name="number[]"> <input type="text" size="93" maxlength="93" name="description[]"><BR> <input type="text" size="10" maxlength="10" name="number[]"> <input type="text" size="93" maxlength="93" name="description[]"><BR> <input type="text" size="10" maxlength="10" name="number[]"> <input type="text" size="93" maxlength="93" name="description[]"><BR> <input type="text" size="10" maxlength="10" name="number[]"> <input type="text" size="93" maxlength="93" name="description[]"><BR>[/code] This is the code that I have put together. [code] if (!isset($_POST['Submit'])) { $_POST['description'] = array(     'description[]',     'description[]',     'description[]',     'description[]',     'description[]',     'description[]',     'description[]',     ); $_POST['number'] = array(     'number[]',     'number[]',     'number[]',     'number[]',     'number[]',     'number[]',     'number[]',     ); { if (!empty($_POST['number']))   foreach($_POST['description'] as $key=>$description) {   if ($description == '') continue;   $description_esc = mysql_real_escape_string($description);   $number = intval($_POST['number'][$key]);   $query = "INSERT INTO parts (description,number) VALUES ("     . "'{$description_esc}', "     . "{$number} )"; mysql_query($query) or die(mysql_error().$query); }[/code]
  19. I have a designed a form that people will fill out to generate a work order for a piece of equipment when it fails. I have created relational (I think) databases, where the tables are all normalized, but am not sure how to tie it all together now. As an example I have the following tables, with their purpose: workorder - majority of the data goes in this table parts - the parts number and parts descriptions go in this table employees - this table contains the employees data and the employee who generated the workorder go in here workorder_parts - to tie the workorder and parts tables together workorder_employee - to tie the workorder and employee tables together My host does not offer innodb table type so I need to do this manually When I create the query to INSERT the data to the DB table, am I using INSERT INTO [color=red]TABLE[/color]    where [color=red]TABLE is the workorder, parts or employees tables, or is it the workorder_parts, etc. table.[/color] I am thinking it is the main (parent) tables, but I don't understand how I will tie them together.  As an example, if I use the parts table, how do I tie it together so that the parts number/description in the parts table are referenced to the workorder number they were generated from? Here is the code I am using: [code]if (!isset($_POST['Submit'])) { else { $work = $_POST["work"]; $sched = $_POST["sched"]; $name = $_POST["tech"]; $site = $_POST["site"]; $serial = $_POST["serial"]; $hours = $_POST["hours"]; $starts = $_POST["starts"]; $issue = $_POST["issue"]; $severity = $_POST["severe"]; $resolution = $_POST["resolve"]; $assistance = $_POST["assist"]; $safety = $_POST["safe"];     $number = $_POST["number"];     $description = $_POST["description"]; { if (!empty($_POST['number']))   foreach($_POST['description'] as $key=>$description) {   $description_esc = mysql_real_escape_string($description);   $number = intval($_POST['number'][$key]);   $query = "INSERT INTO parts (description,number) VALUES ("     . "'{$description_esc}', "     . "{$number} )"; mysql_query($query) or die(mysql_error().$query); } mysql_query ("Insert into `workorder`(work, sched, site, serial, hours, starts, issue, severity, resolution, assistance, safety) VALUES ('$work', '$sched', '$site', '$serial', '$hours', '$starts', '$issue', '$severity', '$resolution', '$assistance', '$safety')")or die(mysql_error()); mysql_query ("Insert into `employees` (name) VALUES ('$name')")or die(mysql_error()); [/code]
  20. I am trying to create some code so that the data inputted into a form will end up in a database, but I am running into some problems that are related to my php code. Here are the problems.  1.  Everytime I run the script it puts one empty row in the DB and also puts a row with the data in it. 2.  I have seven fields for the parts number and description, but thought I had the code correct so that it would check for an empty field and if it was empty it wouldn't put the empty row in the db, but it puts in empty rows, up to the total of 7 rows.  Could be 4 rows of data and 3 empty, etc. The other issues are database related and will post those in the database section. Here is the code I am using [code]<?php if (!isset($_POST['Submit'])) { ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="1572864"> <center> [/code] All of the form fields go here and are working properly. this is the code for the parts fields <div><center> <input type="text" size="10" maxlength="10" name="number[]"> <input type="text" size="93" maxlength="93" name="description[]"><BR> <input type="text" size="10" maxlength="10" name="number[]"> <input type="text" size="93" maxlength="93" name="description[]"><BR> <input type="text" size="10" maxlength="10" name="number[]"> <input type="text" size="93" maxlength="93" name="description[]"><BR> <input type="text" size="10" maxlength="10" name="number[]"> <input type="text" size="93" maxlength="93" name="description[]"><BR> <input type="text" size="10" maxlength="10" name="number[]"> <input type="text" size="93" maxlength="93" name="description[]"><BR> <input type="text" size="10" maxlength="10" name="number[]"> <input type="text" size="93" maxlength="93" name="description[]"><BR> <input type="text" size="10" maxlength="10" name="number[]"> <input type="text" size="93" maxlength="93" name="description[]" </div><BR> [code] else { $work = $_POST["work"]; $sched = $_POST["sched"]; $name = $_POST["tech"]; $site = $_POST["site"]; $serial = $_POST["serial"]; $hours = $_POST["hours"]; $starts = $_POST["starts"]; $issue = $_POST["issue"]; $severity = $_POST["severe"]; $resolution = $_POST["resolve"]; $assistance = $_POST["assist"]; $safety = $_POST["safe"];     $number = $_POST["number"];     $description = $_POST["description"]; ); { if (!empty($_POST['number']))   foreach($_POST['description'] as $key=>$description) {   $description_esc = mysql_real_escape_string($description);   $number = intval($_POST['number'][$key]);   $query = "INSERT INTO parts (description,number) VALUES ("     . "'{$description_esc}', "     . "{$number} )"; mysql_query($query) or die(mysql_error().$query); } mysql_query ("Insert into `workorder`(work, sched, site, serial, hours, starts, issue, severity, resolution, assistance, safety) VALUES ('$work', '$sched', '$site', '$serial', '$hours', '$starts', '$issue', '$severity', '$resolution', '$assistance', '$safety')")or die(mysql_error()); mysql_query ("Insert into `employees` (name) VALUES ('$name')")or die(mysql_error()); echo "Work Order # '$work' has been Successfully Added to the System"; } [/code]
  21. That solved this particular problem....Thank You very much.  I am going to post another question regarding this.....
  22. [code]foreach($_POST['description'] as $key=>$description) {    $query='INSERT INTO table (description,number) VALUES (\''.mysql_real_escape_string($description).'','.intval($_POST['number'][$key].')';  mysql_query($query) or die(mysql_error().$query);  }  [/code] is there something missing in this code.... when I try to use it, it complains about an unexpected comma, but if I remove the comma in there, it still complains about an unexpected error. With it in with the rest of my code, it causes all php code after it to not function in php....example my mysql_query are not working after this peice of code...
  23. I am hoping someone will be inclined to explain to me how array's work and what type of array I would use.  I have a book that i was reading up on array's but it talks about all the different kinds of arrays and now I am confused. I have a table that was working but I have done some database normilization and now I need to change things around a bit.  I have 7 fields in a form to list a part number (they were called part 1, part 2, etc.) and then I have 7 more fields for a parts description (they were called number 1, number2, etc.).  In my database I have a column called part and another column called number.  I need to create a query where it will insert the data from the 2 fields into the DB, but not add any empty rows if there weren't 7 part numbers or descriptions. I was told to use an array to do this, but I am lost on this, and haven't been able to google anything that really explains (in noobie terms) how an array works or how to set it up. I appreciate any help Ken
  24. I have a form that is filled out and there is one area where they fill in p to seven fields with a part number and then a description in another field.  I have designed a table that has one column for the part number and another column for the part description.  I am not sure how, using a mysql query, to get the information into the database since there is seven rows to be listed.  (if I had seven columns to match up, I know what to do, but with only one column I am not sure) Would I just list the column name seven times in the query?  I am thinking that wouldn't work and there is a better way of doing it. Ken
  25. hmmmm, would I not use the fk as the primary key as well.  I have made all of the **_id columns my primary key.  Do I need to make a separate foreign key? EDIT:  I HAVE THIS ISSUE FIGURED OUT AS FAR AS PRIMARY AND FOREIGN KEYS....THANKS ALL!!
×
×
  • 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.