buffmin Posted August 24, 2011 Share Posted August 24, 2011 I need help please! I am learning php and mysql and am successful at pulling data from my database and placing it in a (editable) 5 column, 4-row table, but cannot figure out how to correctly do the reverse and update the database upon "submit". I do a "loop" to populate the table and am guessing I need a "reverse" loop to pull the data out and submit it, but do not know how to do this and I cannot figure it out. I would greatly appreciate some help! code below.... [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/245612-mysql-database-loop-problem/ Share on other sites More sharing options...
fenway Posted August 24, 2011 Share Posted August 24, 2011 I don't understand. Quote Link to comment https://forums.phpfreaks.com/topic/245612-mysql-database-loop-problem/#findComment-1261504 Share on other sites More sharing options...
Muddy_Funster Posted August 25, 2011 Share Posted August 25, 2011 Yeah, you're not too clear on this one. Is it right to say that: You are rinning a SELECT on a table, displaying the results in a tabled form. Now you want to have the form data update the table that you have SELECTed from when the form submit button is clicked? Is that about right? Quote Link to comment https://forums.phpfreaks.com/topic/245612-mysql-database-loop-problem/#findComment-1261809 Share on other sites More sharing options...
PFMaBiSmAd Posted August 25, 2011 Share Posted August 25, 2011 This is the classic CRUD (Create, Read, Update, Delete) assignment that is given to programming students to see if THEY can research and figure out how to define and write the code to perform each of those steps. The OP has some code to Read the data and display it in a form (which is incomplete and won't submit any data, let alone sets of data that are related back to the correct id/type of each row in the database table.) I recommend that you get the form working correctly before you attempt to try to process the data it submits. Your form input fields are missing name="..." attributes (no data will be submitted to your .php script without them), you will need to use arrays for those names so that you can have multiple/separate sets of data in the form (see this link - http://us.php.net/manual/en/faq.html.php#faq.html.arrays ), and you need to specifically set the array indexes (instead of using empty [], use ['some_identifying_value']) to identify and associate each row of data in the form back to the id/type it is in the database table. Based on the information in your existing code, you could use form field names like - name="slice['.$row['type'].']" name="small['.$row['type'].']" name="large['.$row['type'].']" name="sheet['.$row['type'].']" To see what data your form is submitting, add the following line of code - echo '<pre>',print_r($_POST,true),'</pre>'; Once you get the form to submit the expected data, you can move onto the next step of processing it. Quote Link to comment https://forums.phpfreaks.com/topic/245612-mysql-database-loop-problem/#findComment-1261824 Share on other sites More sharing options...
buffmin Posted August 25, 2011 Author Share Posted August 25, 2011 I apologise for "lack of following the forum rules". As you can see it was my "post#1" so please do not crucify me. I will try my best to follow all rules in the future. Muddy and PFMaBiSmAd, you two guys understand exactly what I am trying to do. In a nutshell, as you can see, I am just trying to display a simple "Pizza" menu on a webpage" and allow the client to edit prices, and then upload his changes. That's all. I appreciate you taking the time to understand. I understand how you emphasize that step 1 should be to focus on getting my form to submit correctly(with field names. I will follow your suggestions and will work on it tonight and tommow and keep you posted. Thank you very much again. Buffmin Quote Link to comment https://forums.phpfreaks.com/topic/245612-mysql-database-loop-problem/#findComment-1262017 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.