Bentley4 Posted April 22, 2011 Share Posted April 22, 2011 Hi everyone, I would like to put up online exercices wth answers. These exercices and answers should only be visible 1 by 1. E.g. you start with Q1, submit yr answer and then you would see the answer. Then push next Q button and the former Q dissapears. How do I put everything in 1 srcecode, 1 php file? Thnx Quote Link to comment https://forums.phpfreaks.com/topic/234431-different-pages-in-1-php-file/ Share on other sites More sharing options...
spiderwell Posted April 22, 2011 Share Posted April 22, 2011 assuming the Q&A are in a database, using pageination (think thats the right term) and set record limit as 1 row per page. the form could have hidden value for next page number and when form posts to itself, you know which page is next (i.e next question) and show that, as well as of course checking the current question and answer. there might be alternative methods but thats what came to me when i read your post Quote Link to comment https://forums.phpfreaks.com/topic/234431-different-pages-in-1-php-file/#findComment-1204819 Share on other sites More sharing options...
Bentley4 Posted April 22, 2011 Author Share Posted April 22, 2011 I don't use a database though. Is there any other way? Thnx for yr response nevertheless. Quote Link to comment https://forums.phpfreaks.com/topic/234431-different-pages-in-1-php-file/#findComment-1204836 Share on other sites More sharing options...
litebearer Posted April 22, 2011 Share Posted April 22, 2011 How are the questions/answers stored? Quote Link to comment https://forums.phpfreaks.com/topic/234431-different-pages-in-1-php-file/#findComment-1204863 Share on other sites More sharing options...
Bentley4 Posted April 22, 2011 Author Share Posted April 22, 2011 Good Q, I just started out with php so I'm pretty much a noob. How are answers stored normally without a database, in an asp file? Quote Link to comment https://forums.phpfreaks.com/topic/234431-different-pages-in-1-php-file/#findComment-1204868 Share on other sites More sharing options...
fugix Posted April 22, 2011 Share Posted April 22, 2011 i would recommend storing them inside of a database...much easier and efficient. but i suppose that you could store them into a file and draw them out as needed Quote Link to comment https://forums.phpfreaks.com/topic/234431-different-pages-in-1-php-file/#findComment-1204871 Share on other sites More sharing options...
spiderwell Posted April 22, 2011 Share Posted April 22, 2011 I just started out with php so I'm pretty much a noob. How are answers stored normally without a database, in an asp file? php is one language, and asp is another, the 2 really dont mix. you could easy store in a text file, using a delimiter to seperate Q from A but then you lose handy functions that databases can easily be used to do, like sorting, filtering, paging and so on. I am sure you could recreate that with a text file, but why reinvent something when you dont have to. Quote Link to comment https://forums.phpfreaks.com/topic/234431-different-pages-in-1-php-file/#findComment-1204890 Share on other sites More sharing options...
Bentley4 Posted April 22, 2011 Author Share Posted April 22, 2011 Hmm, so basically you're saying I should learn mysql as well? Quote Link to comment https://forums.phpfreaks.com/topic/234431-different-pages-in-1-php-file/#findComment-1204923 Share on other sites More sharing options...
spiderwell Posted April 23, 2011 Share Posted April 23, 2011 php and mysql work very well together, practically every dynamic content website will use these 2 together, or if its asp it would be microsoft sql. you dont need to learn very much sql to achieve what you want with a Q & A application. Quote Link to comment https://forums.phpfreaks.com/topic/234431-different-pages-in-1-php-file/#findComment-1205257 Share on other sites More sharing options...
fugix Posted April 23, 2011 Share Posted April 23, 2011 mysql is rather easy to learn and will most certainly benefit you Quote Link to comment https://forums.phpfreaks.com/topic/234431-different-pages-in-1-php-file/#findComment-1205268 Share on other sites More sharing options...
Bentley4 Posted April 24, 2011 Author Share Posted April 24, 2011 K, thnx! Quote Link to comment https://forums.phpfreaks.com/topic/234431-different-pages-in-1-php-file/#findComment-1205502 Share on other sites More sharing options...
Bentley4 Posted April 24, 2011 Author Share Posted April 24, 2011 Hey, I tried to connect a database of Mysql with a phpfile, but I keep getting this strange message. I have a cPanel account on a university network. Here is the php code that I use to connect with the database(which I made correctly, made a username and connected it to the database and gave all privilages): <html> <body> <?php mysql_connect("localhost", "DataBname", "PassW") or die(mysql_error()); echo "Connected to MySQL<br />";?> </body> </html> However, I keep getting this message: "Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'DataBname'@'localhost' (using password: YES) in /webusers/ph6theo/public_html/index.php on line 7 Access denied for user 'DataBname'@'localhost' (using password: YES)" On the cPanel main menu, it says the server name is "descartes" When I try the same code and insert 'descartes' instead of 'localhost' I get the same message with 'descartes' instead of 'localhost' in this message. Why isn't this working? Quote Link to comment https://forums.phpfreaks.com/topic/234431-different-pages-in-1-php-file/#findComment-1205525 Share on other sites More sharing options...
spiderwell Posted April 24, 2011 Share Posted April 24, 2011 one of the 3 or more is incorrect, otherwise it would connect, I suggest contacting the universtiy network administrator to confirm the name of the server, username and password. are you muddling the server name with the name of the database? Quote Link to comment https://forums.phpfreaks.com/topic/234431-different-pages-in-1-php-file/#findComment-1205634 Share on other sites More sharing options...
Bentley4 Posted April 25, 2011 Author Share Posted April 25, 2011 K, thnx spiderwell! I will ask the administrator. Quote Link to comment https://forums.phpfreaks.com/topic/234431-different-pages-in-1-php-file/#findComment-1206072 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.