Jump to content

Barand

Moderators
  • Posts

    24,566
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. You are building your foreign keys the wrong way round, EG ALTER TABLE `programs` ADD FOREIGN KEY (`program_id`) REFERENCES `deal_type` (`program_id`); should be ALTER TABLE `deal_type` ADD FOREIGN KEY (`program_id`) REFERENCES `programs` (`program_id`); program_id is the primary key of the programs table. When it appears in another table (such as deal_type) it is, therefore, a foreign key linking back the programs record. Also CREATE TABLE `deal_type` ( `deal_type_id` int AUTO_INCREMENT, `affiliate_id` int, `program_id` int, `affiliate_deal_id` int, PRIMARY KEY(deal_type_id,affiliate_id,program_id,affiliate_deal_id) -- really? PK should be deal_type_id );
  2. You can't use them for column and table names, they got that correct, but I have never had a problem when using LIMIT ?,?
  3. Unfortunately I do not know your database or table structures and I cannot see the query you are running because it is obscured behind a function. So all I can do (as I did) is provide an example and leave the rest to you.
  4. @Phi11W, thank you for reinforcing what I said in the first reply to this topic.
  5. The problem with that is clicking takes you to that person's profile.
  6. UPDATE mytable SET thedate = NULL WHERE thedate = '0000-00-00';
  7. To use the results of a query you first have to execute the query (not just define a string with incorrect query syntax)
  8. Add the finished button to the first form. When you process the form, first check if the FINISH button was submitted. If it was , redirect to finish.php.
  9. A lot of code there for what is basically just SELECT order_id , order_date , datediff(curdate(), order_date) as age FROM order WHERE datediff(curdate(), order_date) <= 720 ORDER BY age
  10. Either your date is in an unsortable format (ie anything other than yyyy-mm-dd) or you are sorting on a non numeric field so you get an alphabetic rather than numeric order. Post code, my mother told be not to accept links from strangers,
  11. Congratulations on your decision to upgrade from v4 (only 12 years late) I love guessing games. (When is the closing date?) My entry for the "Guess gerkintrigg's problem" is Have you enabled the PDO extension in your php.ini file? (phpinf() will tell you)
  12. Aliases are applied after the query runs but prior to output so they are not available within the query. You need to use ... COUNT(players.deal_id) AS TotalPlayersByDeal, SUM(affiliate_deals.cpa * COUNT(players.deal_id)) as affiliate_cpa_earnings ...
  13. Example <style type='text/css'> body { width: 100%; height: 100%; background-color: #eee; animation: bgfade 15s infinite; } @keyframes bgfade { 0%, 100% { background-color: red; color: white; } 20% { background-color: gray; color: black; } 40% { background-color: blue; color: white; } 60% { background-color: white; color: black; } 80% { background-color: green; color: white; } } </style>
  14. I suggest strtr(). EG $trans = [ '105.f' => "<a href='?search=105.f'>105.f</a>", '106.g' => "<a href='?search=106.g'>106.g</a>", '107.f' => "<a href='?search=107.f'>107.f</a>" ]; $text = "lorem ipsum 105.f dolor sit 106.g amet"; echo strtr($text, $trans);
  15. Multiple @keyframes?
  16. https://css-tricks.com/almanac/properties/a/animation/
  17. Barand

    MySQL JOIN

    I don't see any matching on deal_id, only program_id. You appear to have program_id in the players table and the player_stats table. Which one does it really belong to?
  18. The structure may be clearer to you if you use print_r() instead of var_dump() echo "<pre>"; print_r($html->find('li')); echo "</pre>";
  19. You may find my reply to one of your previous topics of interest here. (I sometimes ask myself why we bother)
  20. fyi - my solution <?php // generate the array $data = []; for ($i=0; $i<100; $i++) $data[] = mt_rand(1, 99); // output array into table, sort, and output again $t1 = array2table($data); sort($data); $t2 = array2table($data); function array2table(array $arr) { $result = "<table border='1'>\n"; $rows = array_chunk($arr, 10); // split the array into rows of 10 numbers each foreach ($rows as $cols) { // process each row $result .= '<tr>'; foreach ($cols as $c) { // process each column in the current row $cls = $c % 2 ? 'odd':'even'; // apply the appropriate class $result .= "<td class='$cls'>$c</td>"; } $result .= "</tr>\n"; } $result .= "</table>\n"; // return the table return $result; } ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Example</title> <style type='text/css'> table { border-collapse: collapse; margin: 20px; display: inline-block; font-family: calibri, sans-serif; font-size: 12pt; } td { width: 20px; height:20px; padding: 2px; text-align: center; } .odd { background-color: #FF8080; } .even { background-color: #C0FFC0; } </style> </head> <body> <?=$t1?> <?=$t2?> </body> </html>
  21. Create a function which outputs data from an array into a table (You do it with the first table so you have some idea how to do it) Generate random array call function to output it sort the array call same function to output it Your html markup is obsolete. I see you have a css file - use it.
  22. Should work <?php $a = 'foo'; $b = 'bar'; echo $a, $b, '<br>'; //--> foobar echo $a . $b . '<br>'; //--> foobar ?>
  23. Unlike print() (which allows only a single argument and you would have to use "." to concatenate with that function) echo() will accept several arguments separated by commas. Either will do.
  24. The tell it which series you are searching ... WHERE trk_series_id = ?
  25. I'd get the date difference (days) between your search date and the airdate and sort on the absolute value of this diff. The three smallest values will be current, previous and next. I.E. ... ORDER BY ABS(DATEDIFF('$searchdate', trk_airdate)) LIMIT 3 or ... LIMIT 1,2 ( if you want to omit the current episode)
×
×
  • 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.