This may be more complex than I think but... How do I make an HTML table display data stored in a MySQL database? Also, how do I make an html form that can post new data to a MySQL database?

    It's not difficult at all. I would just suggest searching for it on Google or something. (I would give you a link directly to a tutorial, but I'm not sure if I'm allowed to link to other PHP sites or not.)

      do you mean these questions literally? i mean... do you know how to connect to a mysql database using php?

      you might want to start with the [man]mysql/man functions in the manual.

        mscreashuns, if you have a link could you please just PM me it?

          Since when cant you display a link to another resource. There are tonnes of links even doing a search here there are tonnes of results you would find.

            Sorry, I wasn't sure and I didn't want to run the risk of getting in trouble. A lot of forums I have been to don't allow linking to sites that are similar to their own (competing sites).

            For inserting data, this link will tell you how to set up a PHP file that will do that. Read it first.

            http://www.tizag.com/mysqlTutorial/mysqlinsert.php

            Then, set up a file with all the information for your table. Create a form with the necessary fields, and make the action the file you just created. Then, where it specifies the values in the PHP file, replace them with the variables you just named.

            You may want to add some if statements to be sure that all the required fields are filled out and an if statement to make sure that the Submit button has a value. If you only want certain people to be able to insert data, I would suggest password-protecting it.

            What I did for one of my forms was add a text box that asked for a password, and then added an if statement that checked to see if the password was correct, and then if it was, it would process the data and all that good stuff.

            For displaying the information in a table, read this.

            http://www.tizag.com/mysqlTutorial/mysqlselect.php

            You may have to play around with it a bit to figure out how to customize it the way you want, but it's really not that difficult.

              Hi MScreashun,

              Then I would like to welcome you to a forum where it is the intention to send people to other sites, if that is where the information is better. Nobody knows it all, and the whole idea of the web -nowadays- is to bring information from multiple places together. Here it is about helping people to solve their problem. Not to be the best website, as far as I know..

              J.

              [edit]
              and by answering peoples questions & solving the problems, you easily become the best forum, and you have no need to worrie about linking to other sites![/edit]

                Thanks for the links, I appreciate it greatly 🆒

                  Thanks leatherback, you've been a big help to ME, and no problem jeranamo, that's where I learned. 😉

                    that is a good website, but how would I make a webform able to change these values and then add to the mysql database? The tutorial you gave me simply reads from the php file to add that information only. I want to be able to enter new data into a simple form that will allow me to add more rows to the database with ease.

                      Then, set up a file with all the information for your table. Create a form with the necessary fields, and make the action the file you just created. Then, where it specifies the values in the PHP file, replace them with the variables you just named.

                      You may want to add some if statements to be sure that all the required fields are filled out and an if statement to make sure that the Submit button has a value. If you only want certain people to be able to insert data, I would suggest password-protecting it.

                      What I did for one of my forms was add a text box that asked for a password, and then added an if statement that checked to see if the password was correct, and then if it was, it would process the data and all that good stuff.

                      Maybe you missed that in my post earlier. If you don't understand something, feel free to ask. 😉

                        are you saying replace the values in that php file with variables and then for the form I create make the fields set those variables? Then after that set the submit action to the php file containing the variables and MySQL connection?

                          here is a line from my controller file:

                          mysql_query("INSERT INTO testtable (filename, type, url, sharemethod, review) VALUES('$filename', '$type', '$url', '$sharemethod', '$review' ) ") or die(mysql_error());

                          How do I make it so the form fields and dropdown boxes will set their values to these variables? I tried setting the names of each form object to the variables, but this method is not working.

                            You should be able to do something like this:

                            <input type="text" name="filename">

                            and if the action is set to that PHP file, then it should work. 😉

                              ah, so I don't need the $ before the vars when i set the form objects then?

                                I don't think so. Try it without and see what happens. 😃

                                  Yeah, with the $, it does not work, without it, it does work. It must auto assume it as a variable when set to a php file for an action.

                                    Perhaps if you posted the code I could help you better. 😉

                                      Oh, that last post meant everything was working 😛

                                        Write a Reply...