Jump to content

Cagecrawler

Members
  • Posts

    247
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Cagecrawler's Achievements

Member

Member (2/5)

0

Reputation

  1. <?php function filter_keys(&$array, $n, $offset) { for($i = $offset; $i < count($array); $i = $i+$n) { unset($array[$i]); unset($array[$i + 1]); //For a more generic function, remove this and then call the function twice. } } Passing the array by reference removes the need to return the function. I haven't tested it.
  2. Don't use w3schools. The information is quite often out of date (they still list .php3 as a php file extension) or just plain wrong. If you really want a beginner site like that, I'd recommend Tizag but the first sections of the manual explain the syntax pretty well. As for the list of other things to learn, xhtml is dead. Use html5, that's where the standard is going. Also, ajax is javascript. The best way to learn is to practice. Write a script for any problem you have, whether it's organising your music collection or grabbing the latest tweets.
  3. You've got an extra semi-colon in there. There should only be one at the end, not after true).
  4. mysql_affected_rows gives you the number of rows affected. Timings you'll have to make yourself.
  5. It's only two lines, it's about as simple as you can get it... And I made a typo - the function is mysql_fetch_assoc, not mysql_assoc.
  6. <?php $query = mysql_query("SELECT * FROM table ORDER BY datetime ASC"); $ids = array(); $startTime = null; while ($row = mysql_fetch_assoc($result)) { if($startTime == null) { $ids[] = $row['id']; $startTime = $row['datetime']; } else if(strtotime($row['datetime']) - strtotime($lastRow['datetime']) > 60*15) { //Within 15 mins of the last row. $ids[] = $row['id']; } else { //Not within 15 mins, so dump the info and start a new row. var_dump($ids,$startTime,$lastRow['datetime']); $ids = array(); $startTime = null; } $lastRow = $row; } Something like this should work.
  7. $newsletters = mysql_assoc(mysql_query("SELECT mens, womens FROM newsletters WHERE email = '$email' LIMIT 1")); if($newsletters['mens'] == 0 && $newsletters['womens'] == 0){
  8. Your routes both have the same name (post) and are overwriting each other.
  9. It's the validator that's the problem, your code produces a valid output. <?xml version="1.0"?> <myroot><title number="12"><titleName>title1</titleName><titleLink>link1</titleLink></title></myroot> Try http://validator.w3.org/.
  10. Something like this should get you started. <?php $input = "15/09/11 - 18/06/11"; //Explode input to get first date. $dates = explode("-", $input); //Explode it again to get the date parts. $dateParts = explode("/", $dates[0]); //Flip the parts around to Americanise the date, since that's what strtotime takes. $time = strtotime($dateParts[1]."/".$dateParts[0]."/".$dateParts[2]); //Compare to the current time. echo ($time - time() > 60*60*24*30) ? "OVER 30 DAYS" : "UNDER 30 DAYS";
  11. You need to look at the GD image functions: imagecreatefromjpeg or imagecreatefromgif imagecopyresampled imagejpeg or imagegif
  12. The Google Contacts API is probably what you're looking for with regards to Gmail accounts. The Windows Live API probably has something similar.
  13. You can work out if it's a multiple by using the modulus operator (%) and then run an if else to compare different multiples. $my_no = mt_rand(1, 100); if($my_no % 3 == 0) { echo "<td style=\"background-color:red\">$my_no</td>"; } else if($my_no % 2 == 0) { echo "<td style=\"background-color:blue\">$my_no</td>"; } else { echo "<td>$my_no</td>"; } Numbers which are both multiples of 3 and 2 (eg. 6) will be coloured red since that comes first in the if else.
  14. You just need to put another for loop around the code that generates the row. for($ii = 0; $ii < $number_of_rows; $ii++) { echo "<tr>"; for ($i=0; $i<$number_of_columns; $i++) { $my_no = mt_rand(1, 100); echo "<td>$my_no</td>"; } echo "</tr>"; }
×
×
  • 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.