Jump to content

denno020

Members
  • Posts

    761
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by denno020

  1. get the system time using PHP - there are built in functions, like date, I think. Check if the time is between the times you want. Log data. To re-run the code, you might need a javascript timer set up that would refresh the page automatically every 15 minutes. But that's if you're using it in a website context.. and I'm not sure how you could be...
  2. lol, you're welcome... I told you what you should have done so you could learn for yourself, QuickOldCar merely gave you the code... Anyway for your next question, can't do it. You need to use AJAX. Again, that reason is to do with where the code is executed.
  3. Alright I've got it to work. Here is the code that I'm using: <?php //connect to database require_once "connect_to_mysql.php"; $sqlCommand = "SELECT * FROM quiz"; $query = mysql_query($sqlCommand,$myConnection) or die (mysql_error()); $quiz = "<table width=600 border=1>"; $i = 0; while ($row = mysql_fetch_array($query)) { $i++; $question = $row["question"]; $answer1 = $row["answer1"]; $answer2 = $row["answer2"]; $answer3 = $row["answer3"]; $quiz .= "<tr><td> $question"; $quiz .= "</td></tr><br><tr><td>"; $quiz .= "<input type='radio' name='Q $i Choice' value='$answer1' />"; $quiz .= "$answer1"; $quiz .= "<input type='radio' name='Q $i Choice' value='$answer2' />"; $quiz .= "$answer2"; $quiz .= "<input type='radio' name='Q $i Choice' value='$answer3' />"; $quiz .= "$answer3"; $quiz .= "</td></tr>"; } $quiz .= "</table>"; mysql_free_result($query); ?> <!doctype html> <html> <head> <title>Test Page</title> <style type="text/css"> </style> </head> <body> <?php echo $quiz; ?> </body> </html> Give that a whirl and see what you come up with . Denno
  4. I'm going to set up something myself so I can do some testing and I'll get back to you. Also, you don't have to do: $i = $i++l simply: $i++; will suffice Denno
  5. $quiz .= "<input type='radio' name='Q" . "$i" . "Choice' value='$answer1' />"; You can try that, but the use of double quotes means that you can place variables into strings without having to escape and all that.. In what way doesn't it work? Does it give an error or anything? Denno
  6. http://www.tizag.com/sqlTutorial/sqlupdate.php http://www.w3schools.com/sql/sql_update.asp Did you honestly search?
  7. trying putting the javascript inside <?php ?> tags, and echoing it out to the page. Then you should be able to print the variable. The problem is that one is client side, and the other is server side. I'm not sure if this would work as expected, but it's worth a try. Denno
  8. I think something like this will work: //Connect to database mysql_connect($host, $dbusername, $password); mysql_select_db($TxQuizdb); //Retrieve Quiz Questions $qquery = mysql_query("SELECT * FROM Module_1_Quiz"); $quiz = "<table width=600 border=1>"; while ($row = mysqli_fetch_array($qquery)) { $question = $row["question"]; $answer1 = $row["answer_1"]; $answer2 = $row["answer_2"]; $answer3 = $row["answer_3"]; $quiz .= "<tr><td> $question"; $quiz .= "</td></tr><br><tr><td>"; $quiz .= "<input type='radio' name='Q1Choice' value='$answer1' />"; $quiz .= "$answer1"; $quiz .= "<input type='radio' name='Q1Choice' value='$answer2' />"; $quiz .= "$answer2"; $quiz .= "<input type='radio' name='Q1Choice' value='$answer3' />"; $quiz .= "$answer3"; $quiz .= "</td></tr>"; } $quiz .= "</table>" echo $quiz; The value in the square brackets next to $row is the name of each column with the question/possible answers in. ' .= ' means append data to the string, so it just adds it to the end. I've got the <table> starting tag outside of the loop, as this will put all of the information into the one table, instead of making multiple tables. I haven't tested the code above, so there is most definitely errors, just play around with it until you can get it to work, but that is the basic idea that you want. Denno
  9. So that doesn't work anymore? You've got the basic idea of what you need to do, is it just syntax somewhere? What doesn't work? What happens when you try to render the page with the code you've just posted? Denno
  10. To update any information in the database you need to do "UPDATE (table name){columns_names - if only updating a couple of columns, otherwise this can be ommited if a value will be placed into every column} VALUES (values)"; Search for a tutorial on using UPDATE, and you should be set . Denno
  11. dont use IE7? lol Sorry for the non helpful answer, but I had to say it . Denno
  12. so you need to know how to get the (i'm assuming) multiple choice options from the database, and make them appear next to a radio button?? Is this correct? It will be fairly simple if this is what you need.... Denno
  13. you will need to cleanse the search data, to make sure php doesn't interpret the spaces as anything other than a space. I can't think of the functions of the top of my head, but a simple google search should find something you need. It will convert spaces into &nbsp (I believe). So look into cleansing of input text. Denno
  14. Oh wait, maybe it's because I never took the $ sign out. Damn it lol.
  15. Pikachu2000 can you please explain why this didn't work then? $content .= "/pages/"; $content .= $_GET['$content']; $content .= ".php"; Is it just because of the lack of { } curly brackets? Denno
  16. Just to make sure, you have named the files in the pages folder as one.php and two.php correct?
  17. Alright, so it will depend on where you put the line of code that says include (blah blah).. If you put that line in the php file that is in /phptest then you will need to specify the path to the file which is /pages/page.php. If the include code line is in the default.php file, then you don't say /pages/page.php, as this will look for another folder called pages. You just say page.php (so $_GET["content"] etc etc) I think it's only a path issue that you're having.. I'll continue to try and help . Denno
  18. Ok can you give me a short brief as to what you want to achieve here? Do you want the index page to link to another php page that is in the sub folder pages? Or is the content pulled from a php page and display in the index page? Denno
  19. Wait sorry, I've just realized what's happening there. I probably should have tried to comprehend the code before I suggested anything lol. Try this: $content .= "/pages/"; $content .= $_GET['$content']; $content .= ".php"; That should hopefully work a bit better . You can put them all on the same line if you want, but it's easier to put them on the 3 lines, at least for me . Denno
  20. Try putting double quotes in here: $content .= $_GET["pages/$content"].'.php'; That might help... Denno
  21. Oh good call! Denno
  22. Possibly. I don't know how but the results() function is.. Denno
  23. surround the javascript with: <script type="text/javascript"> //function goes here </script Need to tell the browser to read the code as javscript, at the moment it's reading it as php. You will also need to echo it out. Or just escape from php (?>) just before the <script type="text/javascript"> declaration, and then back into php (<?php) afterwards. Denno
  24. That for loop will run 7 times I think.. You are incrementing the counter by 10 each time.. What do you mean the page isn't loading? Have you got error reporting turned on for your php? If you're using an online host, and can't edit the php.ini file, then you need to explicitly turn on error reporting. See here: http://php.net/manual/en/function.error-reporting.php Hope that helps. Denno
  25. I assume you're talking about the javascript code? Because I didn't actually give any php code lol. It should work perfectly. Very simple, and effective. Denno
×
×
  • 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.