Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/234431-different-pages-in-1-php-file/
Share on other sites

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

 

 

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.

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.