Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. $url = 'http://www.youtube.com/vid?id=bla'; $urlParts = parse_url($url); if ($urlParts['host'] === 'www.youtube.com' || $urlParts['host'] === 'youtube.com') { //youtube $params = array(); parse_str($urlParts['query'], $params); echo $params['id'];//bla }
  2. BAD, BAD mods! How dare you keep this forum clean!! Learn HTML & CSS? Pay someone to do it for you? What is it exactly you want to appear?
  3. I left it out because it doesn't needed it. value_field_id links to field_id. Try it!
  4. echo ("<tbody> <tr bgcolor=\"$row_color\"> <td>" . $row['first_name']
  5. Because the dot acts as the concatenation-operator (join 2 strings together). If you want an actual dot you need to write it as a string like $image.'.'.$extension
  6. That's because it's: echo ("<tbody> <tr bgcolor=\"$row_color\">
  7. echo ($i%2 ? 'odd' : 'even'); Only keeps working if you never delete rows. if ($row_count == 1) { $row_color = $color1; $row_count = 0; } else { $row_color = $color0; $row_count++; } Is an unnecessary waste of resources. $color = 'even'; while ($row = mysql_fetch_assoc($result)) { echo '<td class="', ($color = ($color === 'even') ? 'odd' : 'even'), '">' ..
  8. date() re-calculates the date/time every time it is called that's why you need to store it's output if you wish to use it in multiple places that rely on each other of being equal.
  9. Nice, can't believe I over-complicated it so much.
  10. You should modify the code so that it detects newlines and executes: $line = sprintf("% -{$maximumLineLength}s", $line); if (function_exists($callback)) { $line = $callback($line); } $lines .= $line;
  11. Inspired on kenrbnsn's code: $saturday_start = strtotime('first Saturday of May 2010'); $saturday_end = strtotime('last Saturday of May 2010'); $plus7days = 604800; // 86400 * 7 for ($i = $saturday_start; $i <= $saturday_end; $i += $plus7days) { echo date('Y-m-d', $i); } $tuesday_start = strtotime('first Tuesday of May 2010'); $tuesday_end = strtotime('last Tuesday of May 2010'); for ($i = $tuesday_start; $i <= $tudesday_end; $i += $plus7days) { echo date('Y-m-d', $i); }
  12. To do what?
  13. $url = 'http://www.phpfreaks.com/forums/index.php?param=value'; $query = parse_url($url, PHP_URL_QUERY); $get = array(); parse_str($query, $get); echo $get['param'];
  14. ignace

    Help, how.

    Remove positive, negative from your statements table. Create a users table and create the intermediary table votes which has the fields: statement_id, user_id, positive_negative. Insert 1 for a positive vote, -1 for a negative vote.
  15. Yeah, and what do you expect of me now? That I write this for you, for free? I already did more for you then I had to. Either try it yourself or pay me.
  16. No it would be best to keep all calculated data out of your database and store only the required values, perform the calculation in your application. The reason for this is simple, if you modify any of each value then your total is wrong (UPDATE anomaly). You can use INSERT INTO .. ON DUPLICATE KEY UPDATE ..
  17. INSERT INTO table SET goals = .., assists = .., total = goals + assists, points_per_match = total / appearances This being said it's best to keep calculated data out of the database. DECIMAL(8,2) Makes for 6 digits before the . and 2 after.
  18. Post it so everyone can help you, remove credential details if any.
  19. Post both tables and their columns + indicate any foreign keys and to what they reference.
  20. ignace

    Help, how.

    Create your table that will hold your statements and a table that holds your users, create an intermediary table that will hold votes for a user on a statement and make them the primary key so that they can not vote twice. users (id (PK), ..) statements (id (PK), ..) votes (statement_id (PK), user_id (PK))
  21. $score = ''; $position = 0; $hiddenPositions = 0; while ($row = mysql_fetch_assoc($result)) { if ($score != $row['score']) { $score = $row['score']; $position = $hiddenPositions + $position + 1; $hiddenPositions = 0; } else { ++$hiddenPositions; } echo $position, ' ', $score; }
  22. function wrapify($text, $maximumLineLength = 70, $callback = '') { $words = explode(' ', $text); $line = ''; $lines = ''; foreach ($words as $word) { if (strlen($line . $word) > $maximumLineLength) { $line = sprintf("% -{$maximumLineLength}s", $line); if (function_exists($callback)) { $line = $callback($line); } $lines .= $line; $line = ''; } $line .= $word . ' '; } if (!empty($line)) { $line = sprintf("% -{$maximumLineLength}s", $line); if (function_exists($callback)) { $line = $callback($line); } $lines .= $line; } return $lines; } function wrapifyCallback($line) { return "# $line #\n"; } $text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' . 'Ut dictum mattis lobortis. Phasellus velit mauris, mattis non accumsan in, ' . 'elementum auctor tortor. Praesent eget dui nec odio egestas ullamcorper. ' . 'Sed gravida bibendum quam. Nullam varius augue a quam iaculis fermentum nec et enim. ' . 'Nullam vel sagittis tortor. Cras a ultrices.'; $maximumLineLength = 70; echo str_repeat('#', $maximumLineLength + , "\n", wrapify($text, $maximumLineLength, 'wrapifyCallback'), str_repeat('#', $maximumLineLength + , "\n"; Outputs: ############################################################################## # Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut dictum # # mattis lobortis. Phasellus velit mauris, mattis non accumsan in, # # elementum auctor tortor. Praesent eget dui nec odio egestas # # ullamcorper. Sed gravida bibendum quam. Nullam varius augue a quam # # iaculis fermentum nec et enim. Nullam vel sagittis tortor. Cras a # # ultrices. # ##############################################################################
  23. Why bother asking, try it and you'll see for yourself if it works. And for the record, yes it works.
  24. There are programmers for a reason. To do the things you can't on a software/hardware-level.
  25. ignace

    Help, how.

    Unless they remove their cookie each time they press it, then they can keep pressing it as long as they could possibly endure. Cookie's can be removed, IP's can be changed, service's like 10-minute mail make it possible to fool e-mail activation. Let them register to be able to press the button and ask for something that is unique to the person and can not be guessed/changed so easily like a SSN in USA so they can't have multi-accounts.
×
×
  • 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.