PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hi everybody,
Here is the code for creating a website,please have a look on the attachment(It shows how my web page looks like).I have 3 forms in each row and I have almost 2000 rows.
1)my problem is whenever I choose an option from one of the forms,It shows the result for the whole coulmns (example :If I choose passed on the first row and I click submit ,It shows passed for the all the rows in this column)
So please help me if you can give me a script that it works properly.
2)Also I have another problem.my problem is each form works seprately from the other.I mean I can not see the result of 3 forms together.it does not save the result from the previous column?
Yes, there is at least one extra closing </form> tag, but the basic problem is the design of such a user interface. It may be possible to do it the way you've set it up, but I would not do it that way. The usual interface is to have a single "Edit" button in each row, and when that button is clicked, that row is displayed in another window, with a single form that the user can edit. That can be extended to allow multiple rows to be edited, but that requires more code, and would probably be used only if it's expected that many rows will need to be edited in one session. If you may have a thousand rows, I don't think you want to display all of them on the same web page! In other words, I think the whole user interface needs to be reconsidered.
Thanks alot for all your replies.Yes you are right.I deleted the extra </form> and I edited my code.yes I think your idea is better.but what I should do with the last three columns ?I mean for example what I should put under Item flag for each row as default?
my next step is that I have to enter all the form result in the database.Also I have to make a search bottom that the user can search the item information based on the item ID or Item name.
So what is the easiest way to do that???
If I Do not make an edit bottom and simply want to change this script how can I change it?Because I have put all of them in the while loop .but I want to have the result of each row separately on the same page???????????
You are asking questions that would take many, many hours of discussion, clarification, and explanation to answer. A forum is not a practical place to learn how to design a user interface. I will suggest a few questions you should ask yourself, to clarify your objectives:
What is the purpose of this page? Is it to display the content of the database? Is it to select one or a few rows to edit? Is it to edit certain rows? (And the answer is NOT "all of the above".)
Is it really necessary to display all 2,000 rows? Are there criteria by which only the rows that may need editing could be displayed?
How many rows will the user need to update during one session, typically?
After updating some rows, is it necessary to confirm by re-displaying those rows?
Think of this operation from the viewpoint of the user. If you were using this application, what would make sense to you? How would you know which rows needed to be updated? How would you know what selections to choose? What mistakes would you be likely to make?
Thanks for your reply.
1)The purpose of this page is to show the contents of the database,also it should be possible to change the last columns in the database.I mean if I select sth on the website ,and I click submit it should be saved in the database as well.and If i change sth in the database it should shows the change on the website.
2)It is necessary to show all the 2000 rows at the beginning,when sb login.but when sb search an item only based on the rows Name or ID.It only shows that specified result.
3)The user should be able to search any item that he want and then update them if he wants.(This website is for testing some items and it will update the result whenever a tester update the result)
4)I want that anything a user update when the user click submit .It should shows the the same page with the updated result.the update will remain until sb else update the same item again.the update result should goes to the database as well.
It was some explanation that u can have a better understanding.But I guess my code is ok.But at this time,I just want to add some if else statement in the in submit code that I can have the result of each form separately and the result will be submitted to the same page.
Could you please write that script for me???I really Do not know how to write it.because whatever I try, I realized that my while loop do not let me to do that?
I'm sorry, but "The purpose of this page is to show the contents of the database" is not helpful. It doesn't explain what the real purpose of the page is. I can't even imagine a web page that displays 2,000 rows of data! It would mean more if you said something like "The user will submit a search request for records that meet certain criteria based on Name and Type of item, then the user will be able to update 3 specific columns in those records." You don't need to say that the updates will be stored in the database, that's what "update" and "edit" means.
Now we are back to the issue of having so many <form>s on this page. This seems to me to be a bad practice. Even if the user might only need to update one column, it could all be done with one submit for each row.
It seems that your main question, then, is how to display the updated data. If you save the search criteria, either in hidden fields of the form, or in session variables, all you need to do is refresh the page after you update the database, in your *****.php script.
If you really insist on displaying everything from the database, at least look into pagination. I also still don't understand why you need three forms per item.