I'm still a new php beginner, in fact I just started learning couple a days ago.
I love to learn and implement at the same time on real scripts because that's motivate me to continue learning.
Yesterday I put my hands on an open source script (File Uploading Script)
And the script is pretty simple, and I want to create categories in the script
Example: When someone would like to upload he can choose the categorie of the file so it can be added there. I should create the values of the categorie (either in MYSQL or from Control panel)
What I want: I want you guys to tell me what exactly I should be doing. for example U should create something and something to do this. and that's all.(no accurate steps)
I know how to deal with mysqls and with php but I would like to get hints of what every programmer will should do that is all.
[DB Part]
You'll need to create a table contains 2 or 3 fields:
catID field (would be a primary key & autoincrement)
catName field (contains tha category name)
you can add a parentID (to have the catID of the parent category if there is any), imho, no real need for it as a beginner
you will need to link this table with files table taking catID as the foriegn key
[Form Part]
You can either list the categories in the uploading form, to be in a combo box, dropdown list, or even a check box, then insert it in the DB within the form,
or you can let the you user chose the category first before you show him the uploading form, then in your script you register the the catID in a session, & later when you upload the file you use that catID value
see?
Related
Im not a webdev, Im learning all this stuff on the go and I stuck with this stage with my project.
I have a website people can register to use it, so I can store users already. I have a table with different items (item_id, item_name, item_owned). My problem is, every users should have the same list of item, but they can select if they have this item or not on thier own profile.
I could do it make the db and the items are selectable, the db shows 0 if you dont have it or 1 if you have it. But every user sees the same item_owned data and I need it to be user specific.
How can achive this? What structure should I use with the database? Do I need any special libraies beside HTML, PHP, SQL?
Thank you!
I have created a table in mysql database using php, and also i can displayed that table on the web form, But the thing is that i want to do, I have six field in my table.
That are,Sr_no which is auto increment, Process_no, Process Name, Ownership, Sheet Revision_no and Revision Date.
Now i want to make a dynamic tree view type in my field Process_no.
For eg: i have the value in that field M01, so when i'll click on M01 then there should be a sub-list under it, such as M01.1, M01.2,.... and so on. and this thing i want in every column of that field.
i had tried a lot but fail to do it.
if you have any solution or any code for it, then please help me.
i'm not a experience candidate, new at php and mysql.
so please help.
I'm currently developing a database/website server interface to facilitate inputting data for a data collection project. There are two types of additions being made to the database: A and B here. Some of the tables in the database that handle these entries are as follows:
dcs_projectname_a
dcs_projectname_b
Each of these have tables for all the required input fields in addition to things like creator, timestamp, etc.
The pages on the website facilitate three different options: add, view, and edit. Each page for each type of entry performs the respective function. That is, the add page adds, view page views, etc.
I am just about done; however, there is a major challenge I haven't really confronted yet: concurrency. There will be multiple users adding content to the database at the same time. Each entry is given its own specific id and there CANNOT be any duplicate id's. That is, the first a entry is A000001, the next is A000002, and so on.
On the add and edit pages, there is a disabled field for the user to view the id for other uses when physically documenting entries.
What I need to figure out is how to implement concurrency management so that when users are concurrently adding a's that they will not be under the same id and row.
The add page automatically generates the id to be used by accessing the database's most recent id and adding one.
My thought was to create a new row in the table every time the add page is opened and give it the calculated id. Then, when information is added it performs a modification to that existing row. This way, if another user opens the add page while another entry is currently being added it will be given the future id, not the same one.
With this method I need a way to delete this entry if the user leaves the add page or closes the browser. Then, I also need other users with open add pages to automatically update their id's to one less when the first user (or any other user less than the most id being used) leaves their add page and cancels the addition.
This is kind of a complicated explanation and if you don't understand let me know and I'll try to answer as best as I can. Any help is much appreciated!
Thanks
There's a number of solutions to your problem, but you seem to have made things harder by having your application generate the record IDs for you.
Instead, you could just be using MySQL's AUTO_INCREMENT functionality to automatically generate/increment the record ID for you (upon insert). MySQL will ensure that there are no duplicates, and you can get rid of the extra database call to retrieve the most recent ID.
Ok, I'm pretty sure I'm not the first one to run into this, I just don't know the right words to search for a solution.
Consider the following database tables (simplified for this question):
database tables http://www.nth-root.nl/public/images/wolf/cat_attr.png
As you can see in the picture, there is a category table that holds product categories and an attribute table that holds different attributes. For instance: Color (for clothing), Capacity (for mp3 players), etc.
The third table, in the center of the picture, links the attributes to the categories.
Now in the backend I have an 'Edit category' page with a form to edit (or add) a category. On the same page I want to display a list of dropdown lists in order to manage which attributes are linked to the current product category.
backend http://www.nth-root.nl/public/images/wolf-commerce/edit_category.png
It uses jquery to add / delete dropdowns.
The problem is: how do I manipulate the data in the category_attribute table, using the $_POST data of the form.
The lazy solution would be (and yes I've done this in the past):
1. Delete all current rows in category_attribute for the given category
2. Then insert all selected attributes to category_attribute
But this isn't very efficient, it deletes and re-adds all rows even if someone only changes the category's title.
So I'm looking for a way to do the right inserts, updates and deletions:
1. Delete the rows that don't appear in $_POST (the dropdown has been removed)
2. Update the rows that are changed (another option from the dropdown has been selected)
3. Insert rows that are new (a new dropdown has been added)
I'm just not sure how to do it or where to find a good example. It's probably easy to do with some ajax but I am looking for a solution that's purely php, comparing the $_POST values with the values in the database.
If someone knows a good article that explains the best (and most efficient) solution, please let me know, I'd be very grateful.
-edit-
I had included some pictures to clarify my question, but stack overflow refused to include them because my reputation is too low, so I hope my question is clear enough without the images.
-edit2-
Now I have enough reputation, I've added the images.
Thanks in advance,
Nic
Insert and Update:
You can insert a hidden input with the ID records.
Those who are new will reset this ID, so you do the insert.
The ID's that have filled you make an update. If you only want to perform the update really changed the items you can create a hidden input "UPDATED" with value "0". Via javascript you can check if the combo has changed, so that input marked as "1".
Exclusion:
Likewise you can do to exclusion, creating a hidden input scoring records that should be deleted when the user clicks to remove.
Do not know if it's the appropriate way for you, or if you expect a more practical solution.
I have a website and I want to make it easier for someone to change certain information being shown without them having to edit the HTML/PHP and using FTP.
At the moment I have this information in a php file which is included in the MYSQL query.
It would be a lot easier if this was done using a form, say a text field where a person can type the table name and it updates on the main page and starts displaying that table instead.
Sorry if I haven't explained this well. :(
I have a good news for you.
Every php/mysql-driven site in the world is made this exact way - to edit site contents using HTML form.
Even first PHP version name was PHP/FI, stands for Form Interpreter.
Even better, a site user doesn't have to deal with mysql - it's all being done in PHP. No need to type table names into form field - all table names already written in PHP code.
Usual PHP application being connected to just one mysql database - so, no need to choose.
As for the tables, it's being done this way: a user selects some human-readable matter, like "Latest news" and being redirected to the PHP script called, say, news.php. this script runs a query for the news table in the database and outputs some HTML formatted news highlights!
Even more, you don't even need to program! There are plenty of ready-made programs, such as Wordpress
store what you want to be editable in a mysql text field.
remove tags you dont want him to see
in the form echo the editable information in a textarea
have him edit
add tags
update the mysql
note depending on the users knowledge depends on how many tags you would like to remove/add. the less per a field the easier.
on more complicated things i like to have the person log in. if he has permission then all the editable fields have an edit button. if he clicks it it goes to a page with a form that he can use to edit that 1 field