Jump to content

Showing database output on my website?


eduard

Recommended Posts

Ok this made me smile, guys lets try not to run eduardchile off the forum! :). At this point I don't think we want another w3fools. Eduard I would strongly stress you take the time to focus and properly understand one aspect of web development at a time. It is tempting to "learn web development in 21 days etc" but jumping topics like that seems to be confusing you. You may want to invest in some ebooks and wikipedia time as well.
I take it you don't hang out in the PHP subforum much... :)http://w3schools.invisionzone.com/index.ph...mp;highlite=%2B
Link to comment
Share on other sites

  • Replies 72
  • Created
  • Last Reply
The terms "input" and "output" are extremely relative, even though as I hope you've understood, everything in programming can be reduced to them.Keep that in mind when asking about something's input and output. You need to be as specific as you can about it. "output of a database" is way too generic. Like everone else who has replied to you, I think you're still missing the whole point.Apache takes input from the user's HTTP request, and gives output back to the user in the form of an HTTP response.Before fully giving the output to the user, Apache starts PHP giving to it the HTTP request as input, and waits to get an HTTP response.Before fully giving the output to Apache, PHP could (if you instruct it to) give to MySQL input in the form of an SQL query, and MySQL could give the so called result set as output back to PHP. PHP could do this 0, 1, 2 or more times.After taking a result set as input from MySQL, PHP can use it for anything, like outputting something back to Apache based on whatever is the result set.THAT IS IT! ALL OF IT! Everything else about databases comes down to this. There's no way to "view" a database without a tool, there's no way to output anything other than a result set, and a result set is only being given to languages like PHP - it's not something "visual".A database is not something a client should view. They should view the output of your PHP file by making HTTP requests to the Apache server it is running on. Nothing more, nothing less.
Thank you very much! (indeed a lot of news!) But I am always wondering: Shouldn´t this be ´lesson 1´?
Link to comment
Share on other sites

I take it you don't hang out in the PHP subforum much... :)http://w3schools.invisionzone.com/index.ph...mp;highlite=%2B
:) Jeeze I feel bad for ever hesitating on a post. eduard google is your friend! Use it till you max out there servers!
Link to comment
Share on other sites

Ok this made me smile, guys lets try not to run eduardchile off the forum! :). At this point I don't think we want another w3fools. Eduard I would strongly stress you take the time to focus and properly understand one aspect of web development at a time. It is tempting to "learn web development in 21 days etc" but jumping topics like that seems to be confusing you. You may want to invest in some ebooks and wikipedia time as well.
But 6 months is as far as I know more than 21 days!
Link to comment
Share on other sites

I was actually referring to such tutorials and books that carry that sort of title. How have you spent those six months? What do have you been able to understand at least fairly well?

Link to comment
Share on other sites

Thank you very much! (indeed a lot of news!) But I am always wondering: Shouldn´t this be ´lesson 1´?
Not quite, because there's quite a lot of terminology there. Yes, in all cases, the terms just label certain kinds of input and output, but that's typically an overwlelming concept to wrap one's mind around. Heck, you haven't fully wrapped your mind around it, despite it being the one concept you're able to figure out when I give you explanations with it.If you did wraped your mind around it, you would stop asking for "visual" things, and you'll realize it's all about getting an output as an input to something that will (over the course of several other input/output passes) lead to the visualization. You'll see how/if things are directly chained together in this input/output sequence, and the only questions you'll have is if there's an easier (or more direct) way to what you may already be envisioning in one way.(And I cencerely hope I just blew you mind...)
Link to comment
Share on other sites

I was actually referring to such tutorials and books that carry that sort of title. How have you spent those six months? What do have you been able to understand at least fairly well?
Do you think this is the only thing I have to do? VERY WRONG!!!!I´ll tell you one thing! I wake up at 6.30 and I go to bed 1.00 6/7 days a week!P. s. As I have written before, I hate prejudices!
Link to comment
Share on other sites

Not quite, because there's quite a lot of terminology there. Yes, in all cases, the terms just label certain kinds of input and output, but that's typically an overwlelming concept to wrap one's mind around. Heck, you haven't fully wrapped your mind around it, despite it being the one concept you're able to figure out when I give you explanations with it.If you did wraped your mind around it, you would stop asking for "visual" things, and you'll realize it's all about getting an output as an input to something that will (over the course of several other input/output passes) lead to the visualization. You'll see how/if things are directly chained together in this input/output sequence, and the only questions you'll have is if there's an easier (or more direct) way to what you may already be envisioning in one way.(And I cencerely hope I just blew you mind...)
´cencerely´ is ´sincerely´?
Link to comment
Share on other sites

Is this correct? 1 I have to make a php page with data for the database.2 I have to make a php page (with html) in it.3 This php page interacts with MySQL > output in a database4 Because the php page of 2 has html in it, I can show the output of the database (3) on my website?

Link to comment
Share on other sites

1 I have to make a php page with data for the database.If you want a user other than youself to add data to the database, and then to show this data later. you would use php, html (specifically form input fields), sql to insert data into database, but you yourself could use this page with form, or phpmyadmin to add data.2 I have to make a php page (with html) in it.A php page does not need to have html, if is not going to display data within html. It maybe just a function to process the data from database (using sql as well) when called upon.3 This php page interacts with MySQL > output in a databaseMust be php page using php, sql, and would usually combined together within (4).4 Because the php page of 2 has html in it, I can show the output of the database (3) on my website?To show data from database you would include the data output within html tags, or include the html in php output + data<h1><? echo myrow['title]; ?></h1>OR<?phpecho '<h1>'.myrow['title].'</h1>';?>

Link to comment
Share on other sites

1 I have to make a php page with data for the database.If you want a user other than youself to add data to the database, and then to show this data later. you would use php, html (specifically form input fields), sql to insert data into database, but you yourself could use this page with form, or phpmyadmin to add data.2 I have to make a php page (with html) in it.A php page does not need to have html, if is not going to display data within html. It maybe just a function to process the data from database (using sql as well) when called upon.3 This php page interacts with MySQL > output in a databaseMust be php page using php, sql, and would usually combined together within (4).4 Because the php page of 2 has html in it, I can show the output of the database (3) on my website?To show data from database you would include the data output within html tags, or include the html in php output + data<h1><? echo myrow['title]; ?></h1>OR<?phpecho '<h1>'.myrow['title].'</h1>';?>
Thank you very much!
Link to comment
Share on other sites

What do I write on the php page of data for the database (I want to make a product database!) and what on the php file which interacts with MySQL?<html><body><?phpproduct 1price, quantity in stock 6

Link to comment
Share on other sites

You can use insert queries to add data to the database, and you can use select queries to get the data to display. You can also use update and delete queries to change the data. All of these are covered in the tutorials.

Link to comment
Share on other sites

1 I have to make a php page with data for the database.If you want a user other than youself to add data to the database, and then to show this data later. you would use php, html (specifically form input fields), sql to insert data into database, but you yourself could use this page with form, or phpmyadmin to add data.2 I have to make a php page (with html) in it.A php page does not need to have html, if is not going to display data within html. It maybe just a function to process the data from database (using sql as well) when called upon.3 This php page interacts with MySQL > output in a databaseMust be php page using php, sql, and would usually combined together within (4).4 Because the php page of 2 has html in it, I can show the output of the database (3) on my website?To show data from database you would include the data output within html tags, or include the html in php output + data<h1><? echo myrow['title]; ?></h1>OR<?phpecho '<h1>'.myrow['title].'</h1>';?>
This is good as no. 1?<html><body><?phpproduct price quantity in stock a $ 10 5 b $ 7 6 c $ 12 4 d $ 8 12 e $ 11 4 f $ 5 9 g $ 6 10 h $ 14 9 i $ 6 15 j $ 8 12 ?> </body> </html>Tgh
Link to comment
Share on other sites

Ok, thanks! But that´s the next step! (when the database is created!) This document is the very first step: data for the database!and Where do I save the file? In the htldocs folder of my webserver?

Link to comment
Share on other sites

This is good as no. 1?<html><body><?phpproduct price quantity in stock a $ 10 5 b $ 7 6 c $ 12 4 d $ 8 12 e $ 11 4 f $ 5 9 g $ 6 10 h $ 14 9 i $ 6 15 j $ 8 12 ?> </body> </html>Tgh
No that's what is known in the trade as absolute crap or gibberish, where's the form? where's form inputs I mentioned, you fill in the info relating to 1 product at a time, you then submit, which usually takes you to a separate page which adds this info to the database (php, sql to connect to database in insert data entered in form), and then returns you back to the input page for the next product details input.
Link to comment
Share on other sites

This tutorial has two good examples. The first shows you how to select data from your database and echo it to your page with no special formatting. The second shows you how to echo your data into an HTML table.
yeah... but I think this is actually step 1...http://www.w3schools.com/php/php_forms.asphttp://www.w3schools.com/php/php_mysql_connect.asphttp://www.w3schools.com/php/php_mysql_create.asphttp://www.w3schools.com/php/php_mysql_insert.asp
Ok, thanks! Where do I save that file? In the htldocs folder of my webserver?
Ed...just STOP for a second and listen to us. Please. This is getting out of hand. Step 1 is getting information INTO the database. This means you have to CREATE a table for the information to go into. Then you INSERT that information into the table. What you wrote is pseudo-code at best, and if you read the tutorials you would know that it is wrong. We have told you the two primary ways of CREATING/INSERTING/UPDATING. You either make a form that submits to a PHP script that does the CREATE/INSERT/UPDATE for you, or you do it manually in phpMyAdmin. That's it. You don't write arbitrary data in a PHP file and hope for the best. You have to FOLLOW the steps. There IS a reason for their existence. We've already gone over CONNECT and CREATE at length with you already, so you should already have a products table with fields for the different types of information you want to store for each product.If you don't want to use phpMyAdmin, you should be building a form in HTML that when submitted, will send the information to a PHP script that will take in the data, check that the information was submitted correctly, CONNECT to the database and table, and then INSERT that data into the table. (there are way to combine that all into PHP file, but we're nowhere near that point yet with you.)
Link to comment
Share on other sites

But aren´t you steps ahead? This is just an ordinary file (like: my_db) which I will use in the database (so before creation of a database) You are writing information AFTER the database is created!

Link to comment
Share on other sites

This is just an ordinary file (like: my_db) which I will use in the database
That doesn't make sense, you don't use a PHP file "in the database". You use PHP files to interact with the database.Have you created the database yet? Have you created the product table yet? You need to do both of those first. What you are showing is not creating a database or table. You create the database and table inside phpMyAdmin, or you use CREATE DATABASE and CREATE TABLE queries to set them up. Creating your database and tables is step #1 before you can use either of them. You can't use something you haven't created yet.In other words, all of the information we give you is after the database is created. You need to create everything first, then add data to it. You don't add data when you create it, you add data after.We already spent a lot of time with you talking about creating these, so people assume you've already done that.
Link to comment
Share on other sites

But aren´t you steps ahead? This is just an ordinary file (like: my_db) which I will use in the database (so before creation of a database) You are writing information AFTER the database is created!
No. nothing can come before creating the database and table. If you read the tutorials, that's what they have you do first. You can't INSERT into something that doesn't exist. AND FOR THE LAST TIME....PHP HAS NOTHING TO DO WITH DATABASES OTHER THAN BEING ABLE TO CONNECT TO ONE AND GET/SET DATA. that's it. it's not in the database, and the database is not in the PHP. Again, because it can't be stated enough, you ABSOLUTELY must understand how these languages (HTML/PHP/SQL) interact and recognize what a database is. so, again (and again and again and again)...phew....1) create database and table (it's probably just easier to do this in phpMyAdmin) for your products and add fields for every piece of information you want to save about a product (price, description, stock, etc). You've already done this and we've already help you. Please refer to the tutorials and your past threads. Nothing overly complicated about this at all.* http://www.w3schools.com/php/php_mysql_connect.asp* http://www.w3schools.com/php/php_mysql_create.asp2) HTML - create a form that has inputs so that it can submit data to a PHP script to save the information from the form to a database. The form inputs should match the fields you've made in the table.* http://www.w3schools.com/html/html_forms.asp3a) PHP - create a script that takes in a $_POST or $_GET array for submitting form data to the database* http://www.w3schools.com/php/php_forms.asp* http://www.w3schools.com/php/php_get.asp* http://www.w3schools.com/php/php_post.asp b ) PHP/SQL - once you have the form submitting to the PHP script, and you can view all the data, you are ready to write an INSERT query to submit the information to the database* http://www.w3schools.com/php/php_mysql_insert.asp---after that's all done, and you've gotten that process to work and have saved a few products, you should see them show up in phpMyAdmin, as you add them4) PHP/SQL/HTML - create a PHP file that SELECT's records (products) from your table and outputs them to the browser in the form of HTML markup* http://www.w3schools.com/php/php_mysql_select.asp
Link to comment
Share on other sites

That doesn't make sense, you don't use a PHP file "in the database". You use PHP files to interact with the database.Have you created the database yet? Have you created the product table yet? You need to do both of those first. What you are showing is not creating a database or table. You create the database and table inside phpMyAdmin, or you use CREATE DATABASE and CREATE TABLE queries to set them up. Creating your database and tables is step #1 before you can use either of them. You can't use something you haven't created yet.In other words, all of the information we give you is after the database is created. You need to create everything first, then add data to it. You don't add data when you create it, you add data after.We already spent a lot of time with you talking about creating these, so people assume you've already done that.
All logical!I haven´t created anything, but a DATAbase needs DATA! That´s this document!Besides, creating a database is now a piece of cake (they say in the UK)
Link to comment
Share on other sites

Its easy to create a database, just give it a name, click button, its done. But problem is you don't add data to database, you need a table within the database with fields with appropriate type INT, VARCHAR etc to add the data to.that why you need to supply DATABASE name to to connect to specific database.$databasename = "my_db";$conn = mysql_pconnect("hostname", "username", "password") or trigger_error(mysql_error(),E_USER_ERROR);mysql_select_db($databasename, $conn);and table name to work with data within that table.$sql = "SELECT * FROM mytable_name ORDER BY product_name ASC";$result = mysql_query($sql) or die(mysql_error());while ($row = mysql_fetch_assoc($result)) {echo '<p>Product Name: '.$row['product_name'].'</p>';}?>Now if database 'my_db' exists, table 'mytable_name' exist, and all require field exist such as 'product_name' it will show all the items product names within that databases table.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...