
jhh1987
New Members-
Posts
9 -
Joined
-
Last visited
jhh1987's Achievements

Newbie (1/5)
0
Reputation
-
Apologies....So the below item is the query where i would pull ALL of the data from the table including the OSHA_Poster field. if(strlen($EMPLOYEE_ID) >0 ){$result = mysql_query("SELECT * FROM tbl_Employee_Master where Employee_ID = $EMPLOYEE_ID");} I guess what I am trying to do is start small, grabbing only the OSHA_Poster field and the name fields and populate a form with those values that i can then update any of them and then write them back to the table.
-
The reason that I am using -1 for True is because I have access talking to the database also. This is primarily for importing of files that corporate gives us. Also it is my understanding that the reason -1 comes up as True is that in binary it is 11111111 vs zero which is 00000000 and one which is 00000001. I really dont care honestly, I was trying to do if it is <>0 then display it as true. Using PDO is fine by me, just wasnt sure if it was "wrong" So lets say you have the below query that finds one record from a table called tbl_Employee_Master and then write back a true (-1 or 1) to OSHA Poster. Employee_ID is unique and what would be used to find the specific employee. SELECT tbl_Employee_Master.Employee_ID, tbl_Employee_Master.Last_Name, tbl_Employee_Master.First_Name, tbl_Employee_Master.Separated, tbl_Employee_Master.OSHA_Poster FROM tbl_Employee_Master WHERE (((tbl_Employee_Master.[Separated])=False)) ORDER BY tbl_Employee_Master.Last_Name;
-
Hello all, I am completely sideways right now trying to get this to work. Basically I am attempting to make a form that fetches results based on a drop down and then populates a text box that the user can then edit. I have several issues, first of all, I would have to use check boxes for if a user has a certain file on record. Which would be editable, however, I have had issues displaying tinyint values of -1 as true and 0 as false. Secondly, writing the data back to the table after clicking a submit button, I have still issues with checkboxes here and am thoroughly confused to if I need to use an array or what here. Thirdly, should I be using PDO or mysql for this? We have an older NAS device that I will be running this on and the firmware is older. All the info is stored in the same table, and would be selecting a single record at a time for a user to edit. I was thinking I would just write back ALL values to the table when submit is clicked? Is that a bad idea? As you can tell I just need someone to kick my butt in the right direction, I feel like I have read all the different ways to skin a cat but confused myself in the process. Thanks
-
Thanks so much for your help ginerjm that '$GF' really helped. Everything is working smoothly now and even updates based off of the onchange action. Result below for others with the same issue. ///////// Getting the data from Mysql table for first list box////////// $quer2="SELECT tbl_Employee_Master.Current_GF as GF FROM tbl_Employee_Master GROUP BY Current_GF, tbl_Employee_Master.Separated HAVING (((tbl_Employee_Master.Separated)=0))"; ///////////// End of query for first list box//////////// /////// for second drop down list we will check if category is selected else we will display all the subcategory///// if(strlen($GF) <>0){$quer="SELECT DISTINCT Employee_ID, Last_Name, First_Name, Separated FROM tbl_Employee_Master WHERE ((Current_GF='$GF') AND (Separated=0)) order by Last_Name";} else{$quer="SELECT DISTINCT Employee_ID, Last_Name, First_Name, Separated FROM tbl_Employee_Master WHERE Separated=0 order by Last_Name";} ////////// end of query for second subcategory drop down list box /////////////////////////// echo "<form method=post name=f1 action='Reports.php'>"; /// Add your form processing page address to action in above line. Example action=dd-check.php//// ////////// Starting of first drop downlist ///////// echo "<select name='GF' onchange=\"reload(form)\"><option value=''>Select GF</option>"; foreach ($dbo->query($quer2) as $noticia2) { if($noticia2['GF']==@$GF){echo "<option selected value='$noticia2[GF]'>$noticia2[GF]</option>"."<BR>";} else{echo "<option value='$noticia2[GF]'>$noticia2[GF]</option>";} } echo "</select>"; ////////////////// This will end the first drop down list /////////// ////////// Starting of second drop downlist ///////// echo "<select name='EMPLOYEE_ID' onchange=\"reload(form)\"><option value=''>Select Employee</option>"; foreach ($dbo->query($quer) as $noticia) { if($noticia['Employee_ID']==@$EMPLOYEE_ID){echo "<option selected value='$noticia[Employee_ID]'>$noticia[Employee_ID] $noticia[Last_Name] $noticia[First_Name]</option>"."<BR>";} else{echo "<option value='$noticia[Employee_ID]'>$noticia[Employee_ID] $noticia[Last_Name] $noticia[First_Name]</option>";} } echo "</select>"; ////////////////// This will end the second drop down list /////////// And then the form has this code to show the report. if(strlen($EMPLOYEE_ID) >0 ){$result = mysql_query("SELECT * FROM tbl_Employee_Master where Employee_ID = $EMPLOYEE_ID");} echo "<style> table, th {border: 2px solid black;}</style>"; echo "<table>"; // keeps getting the next row until there are no more to get if(strlen($EMPLOYEE_ID) >0 ){while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<font size=5 ><b>Report for " . $row['Last_Name'] . ", " . $row['First_Name'] . "</b></font>"; echo "</p>"; echo "<font size=4 ><b><u> General Information </u></b></font>"; echo "</p>"; echo "<tr><td align=left><b><b>Employee ID</td> <font size='2'><td width=120>"; echo $row['Employee_ID']; echo "<tr><td align=left><b><b>Last Name</td> <font size='2'><td width=120>"; echo $row['Last_Name']; echo "<td align=left><b><b>First Name</td> <font size='2'><td width=120>"; echo $row['First_Name'];
-
Right so the current_gf is what corporate would say is the employees current foreman, im simply looking at this field for all GFs employee_id is unique to everyone I meant that everyone who pops up as a GF should have their own record and unique employeeID as well
-
Its basically a huge table...Ill try to show you below Employee_ID | Last_Name|First_Name|Current_GF|TrainingDocument (yes/no tiny int) 1234 Doe John COBB TY -1 2345 COBB TY COBB TY 0 7478 Trombone Rusty COBB TY -1 So I gather a list of the current GF's from the table of employees, yes in theory they all should have a row themselves but this info comes from corporate and is automatically imported and I have had many errors so to assume thats always true would be wrong (like if a new person gets hired as a foreman, but isnt reflected yet on the data).
-
I guess what im asking is how should i assign those foreman IDs? and then from those rowIDs how do i proceed to filter the results? Am i barking up the right tree on this? Im all for the path of least resistance but am relatively new to all of this and was just trying to follow a tutorial.
-
I have attempted to get a php reporting page built for our off site managers to run reports. Because of the number of employees I think it ouwld be best to sort by foreman, then be able to pick from the resulting drop down list of current employees under that foreman. My issue I think really comes from having the first drop down be dynamic in that you would see a list of foremen which comes from a query of the main employees table and then picks up only active employees and their foreman. The tutorials I have seen all reference an 'id" field but since I am pulling the info for the drop down from a query, should I have some sort of rowID? If so how? The tutorial I have found checks to see if you pick a number which I seem to have gotten around but when I do the query and look for $GF (general foreman) then the query comes back empty (this is bolded and underlined below). Should this be some sort of rowID for the general foreman drop down? Below is what I have been able to sort-of get working (adding in the URL handlers I think will be useful for people in the future to be able to bookmark it/send out emails with links already in it etc) Here is the tutorial http://www.plus2net.com/php_tutorial/php_drop_down_list.php Not sure if i understand why he used the $nocitia tags either I know Im close on this but am starting to go crosseyed! Thanks for pointing me in the right direction. <?php require 'config.php'; // Database connection //////// End of connecting to database //////// ?> <!doctype html public "-//w3c//dtd html 3.2//en"> <html> <head> <title>Multiple drop down list box</title> <SCRIPT language=JavaScript> function reload(form) { var val=form.GF.options[form.GF.options.selectedIndex].value; var val2=form.EMPLOYEE_ID.options[form.EMPLOYEE_ID.options.selectedIndex].value; var val3=form.SEPARATED.options[form.SEPARATED.options.selectedIndex].value; self.location='dd3.php?GF=' + val + '&EMPLOYEE_ID=' + val2 + '&SEPARATED=' + val3 ; } </script> </head> <body> <?Php @$GF=$_GET['GF']; // Use this line or below line if register_global is off @$EMPLOYEE_ID=$_GET['EMPLOYEE_ID']; // Use this line or below line if register_global is off @$SEPARATED=$_GET['SEPARATED']; // Use this line or below line if register_global is off ///////// Getting the data from Mysql table for first list box////////// $quer2="SELECT tbl_Employee_Master.Current_GF as GF FROM tbl_Employee_Master GROUP BY tbl_Employee_Master.Current_GF, tbl_Employee_Master.Separated HAVING (((tbl_Employee_Master.Separated)=0))"; ///////////// End of query for first list box//////////// /////// for second drop down list we will check if category is selected else we will display all the subcategory///// if(strlen($GF) > 0){ $quer="SELECT Employee_ID tbl_Employee_Master WHERE Current_GF=$GF"; }else{$quer="SELECT DISTINCT Employee_ID, Last_Name, First_Name FROM tbl_Employee_Master order by Last_Name"; } ////////// end of query for second subcategory drop down list box /////////////////////////// echo "<form method=post name=f1 action='dd-check.php'>"; /// Add your form processing page address to action in above line. Example action=dd-check.php//// ////////// Starting of first drop downlist ///////// echo "<select name='GF' onchange=\"reload(this.form)\"><option value=''>Select one</option>"; foreach ($dbo->query($quer2) as $noticia2) { if($noticia2['GF']==@$GF){echo "<option selected value='$noticia2[GF]'>$noticia2[GF]</option>"."<BR>";} else{echo "<option value='$noticia2[GF]'>$noticia2[GF]</option>";} } echo "</select>"; ////////////////// This will end the first drop down list /////////// ////////// Starting of second drop downlist ///////// echo "<select name='EMPLOYEE_ID'><option value=''>Select one</option>"; foreach ($dbo->query($quer) as $noticia) { echo "<option value='$noticia[Employee_ID]'>$noticia[Employee_ID] $noticia[Last_Name] $noticia[First_Name]</option>"; } echo "</select>"; ////////////////// This will end the second drop down list /////////// //// Add your other form fields as needed here///// echo "<input type=submit value=Submit>"; echo "</form>"; ?> <br><br> <a href=dd.php>Reset and start again</a> <br><br> <center><a href='http://www.plus2net.com' rel="nofollow">PHP SQL HTML free tutorials and scripts</a></center> </body> </html>