ballouta Posted April 20, 2009 Share Posted April 20, 2009 Hello, In this question i am not asking for a code, but i am asking about the good techniqe used to do the following. I have books list stored in a table in a database, If I want to view all this list with all its fields and edit what I need to modify and then save the fields. if i am reading one row i would echo them in a form then post all the fields again to update the table. BUT in my case, when i have many rows and each row has many related fields, e.g: ISBN Book_Title Book_Price Book_Size etc.. How I would know that this Book_Price, Book_Size, Book_Title is for that specific ISBN !?! In other words, How do I display this list and how do I save it back? thank you Quote Link to comment https://forums.phpfreaks.com/topic/154898-modifying-many-fields/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 20, 2009 Share Posted April 20, 2009 There are many existing table edit/data grid scripts, such as phpMyEdit, no need to re-invent the wheel - http://www.phpmyedit.org/ Quote Link to comment https://forums.phpfreaks.com/topic/154898-modifying-many-fields/#findComment-814733 Share on other sites More sharing options...
laffin Posted April 20, 2009 Share Posted April 20, 2009 U use the SQL WHERE clause with the isbn of the book and updates. this is basic SQL statement, I wud suggest reading some SQL tutorials. Quote Link to comment https://forums.phpfreaks.com/topic/154898-modifying-many-fields/#findComment-814906 Share on other sites More sharing options...
ballouta Posted April 20, 2009 Author Share Posted April 20, 2009 @laffin i know the where clause, and i have used it before many times to update tables Actually the point i am trying to take info about is that when i query those rows from the table and view them, I am imaging this: First row: <input type ='text' name='isbn' value'$row[isbn] /> <input type ='text' name='btitle' value'$row[book_title] /> <input type ='text' name='bsize' value'$row[book_size] /> <input type ='text' name='bprice' value'$row[book_price] /> and i still have many many other rows, how i will name those <input>'s so the update is done successfully (this is if i am thinking in a good way). also same input names... Thank you Quote Link to comment https://forums.phpfreaks.com/topic/154898-modifying-many-fields/#findComment-814918 Share on other sites More sharing options...
laffin Posted April 20, 2009 Share Posted April 20, 2009 The input names dun really matter much. as they are just remapped as $_POST elements keys. but it is all about how u process the $_POST variables. the form input names are just variable names, nothing more but if yer using just <input type='text'> u may want to use a foreach statement instead. if yer asking how to reduce the number of variables cuz its getting messy. you name the form input like a php array <input type="text" name="book[isbn]"> and so on, so when u process the book information, its all in a premade $_POST array $_POST['book'] But forms have no direct relation to how its put into the db. so this question is kinda confusing. Quote Link to comment https://forums.phpfreaks.com/topic/154898-modifying-many-fields/#findComment-814986 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.