Jump to content

wwfc_barmy_army

Members
  • Posts

    320
  • Joined

  • Last visited

    Never

Everything posted by wwfc_barmy_army

  1. Nothing is showing when i run it no. Thanks. Pete.
  2. Hello. I'm reasonably new to PHP, and not sure how to do this IF statement, i need something like this: [code]<?php if ("$qry[editorrating] = 25") { echo "<img src='images/25.png'>"; } if ("$qry[editorrating] = 05") { echo "<img src='images/05.png'>"; } if ("$qry[editorrating] = 1") { echo "<img src='images/1.png'>"; } ?>[/code] But this doesn't work and just dispays all the images, what do i need to change so it just displays one of the images depending on what is in the database? Thanks. Peter.
  3. :( Still no luck with either of the two codes, just doesn't show anything. I will email you all the source code now. Thanks. Peter.
  4. I get this error: [quote]Parse error: parse error, unexpected T_VARIABLE in C:\public_html\RPG\site.php on line 33[/quote] Line 33 being: [code] $now = strtotime("now");[/code] It's all running off a personal web server on my computer at the moment.
  5. Ah sorry, didn't replace all of the code, thats why i got the error. It doesn't print anything and doesn't display an image. Any ideas? Thanks. Peter.
  6. woo, not a noobie any more :P I edited my previous post saying what line 30 was :) Thanks again. Peter.
  7. When using that code i get this error: [quote] Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\public_html\RPG\site.php on line 30 [/quote] Thanks for all your help pkSML Thanks. Peter. **Edit** line 30 is: [code]if (strtotime("$x['dateadded']") > $sevenDays) {[/code]
  8. [quote author=pkSML link=topic=108166.msg435488#msg435488 date=1158412926] Is the dateadded field separated with dashes or slashes?[/quote] Exactly as above, so dashes (2006-09-13) [quote] What error message did you get previously? [/quote] For the [b]second[/b] code i get this error: [quote] Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\public_html\RPG\site.php on line 30 [/quote] Thanks. Peter.
  9. Ok, well i tried the first code but still no image is shown, the second code gives an error. An example of the dateadded field is 2006-09-13. This one should work as it is only 3 days old. Any ideas? Thanks!! Peter.
  10. I don't mind :P I've put that in, but like the last even though the dateadded is less then 7 days ago it doesn't show the image. I've just realised that the date is shown like this: 2006-09-16 , i orginally thought it was different.
  11. I tried changing the Y to y but it still doesn't show anything. I don't know where '$mon, $day, $year' is coming from.
  12. [quote author=pkSML link=topic=108166.msg435291#msg435291 date=1158368531] This code is fixed. I hope the syntax is proper. date(z) does not need to take into account the month because it just returns the day of year. This updated code makes sure that the year is the same. [code]<?php while ($x = mysql_fetch_array($result)) {   list($mon, $day, $year) = explode('-', $x['dateadded']);   $day = date('z', mktime(0, 0, 0, $mon, $day, $year)) + 1; // day of year for datestamp   $thisyear = date("Y");   $today = date("z") + 1; // today's day of year   if ((($today - $day) < 7) && ($year == $thisyear)) {     // show your image here since it's new! echo "<img src='/images/new.gif'>";   } } ?>[/code] [/quote] I ran this, but it doesn't show anything even though the selected record has the dateadded as 3 days ago. Any ideas? Thanks. Peter
  13. No offence but this doesn't help someone new to php like me. Could anyone else help me out a bit more? Thanks. Pete.
  14. I am not sure how to do this, like i said i'm reasonable new to PHP, i currently use 'CURDATE()' to add the date to the database, how do i change it to use as a string of time?
  15. Will this work even though the date is stored (using CURDATE()) into the database as MM/DD/YYYY?
  16. Hello. I dont' quite understand what you are saying. What can i do with the code that i have already? Thanks. Peter.
  17. Thanks for the reply. I tried using that but i get this message: Strict Standards: strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/London' for '1.0/DST' instead in C:\public_html\RPG\site.php on line 27 I'm using this code (includes the changes i made): [code]<?php $sevenDays = strtotime('today -7 days'); while ($x = mysql_fetch_array($result)) {   list($mon, $day, $year) = explode('-', $x['dateadded']);   if (strtotime("$year-$mon-$day") > $sevenDays) {     // show your image here since it's new! echo "<img src='/images/new.gif'>";   } } ?>[/code] Any ideas? Thanks a LOT in advance! Cheers. Pete.
  18. Hello. I am still learning PHP and have been building a site over the last week. I have done well so far, but i've got to a bit where i can't find an answer anywhere. Currently i have a date field that is stored like mm-dd-yyyy, i would like to make it so if the date is less then 7 days old then it will display a 'new' image. I know i need to use an If statement but i'm not 100% sure how to get it to just display it if it's less than 7 days old. Can anyone give me any advice, links or code? Thanks. Peter.  :)
×
×
  • 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.