Jump to content

Recommended Posts

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

I have had issues displaying tinyint values of -1 as true and 0 as false.

 

You should be using 1 for TRUE and 0 for 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.

 

Typically, people have issues with checkboxes because they are only sent in the POST data if they are checked. Not knowing your specific issues, I can't provide any suggestions.

 

 

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.

PDO and MySQL are not mutually exclusive. MySQL is a type of database. PDO is a database extension that you use to interact with a database. You may have meant mysqli_ which is the MySQL specific extension for working with MySQL databases. I would suggest the PDO over the mysqli_ extension. PDO can be used with many different types of databases. So, if you change from MySQL to SQLLite, PostgreSQL, or something else you may not have to change any code. With mysqli_, it only works with the MySQL database. Plus, PDO is easier to understand in my opinion.

 

 

 

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?

 

It's not a bad idea. It just depends on how you need it to work. Without understanding the requirements and the context of the record to be edited, it is impossible to provide a knowledgeable suggestion.

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;

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.