Jump to content

Barand

Moderators
  • Posts

    24,603
  • Joined

  • Last visited

  • Days Won

    830

Everything posted by Barand

  1. 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);
  2. Multiple @keyframes?
  3. https://css-tricks.com/almanac/properties/a/animation/
  4. 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?
  5. 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>";
  6. You may find my reply to one of your previous topics of interest here. (I sometimes ask myself why we bother)
  7. 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>
  8. 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.
  9. Should work <?php $a = 'foo'; $b = 'bar'; echo $a, $b, '<br>'; //--> foobar echo $a . $b . '<br>'; //--> foobar ?>
  10. 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.
  11. The tell it which series you are searching ... WHERE trk_series_id = ?
  12. 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)
  13. As you posted echo $result["fromAddress"]["phone"]; works if $result is an array. If it's an object you need echo $result->fromAddress->phone;
  14. try form code echo "<table>"; for ($i=1; $i<=5; $i++) { echo <<<FORM <tr> <td style="width:70%;">Item $i</td> <td class="text-center"> <input type="hidden" name="equipmentId[$i]" value="$i"> <input name="equipmentQty[$i]" class="eqQty text-center up" type="text"> </td> </tr> FORM; } echo "</table>"; processing code if ($_SERVER['REQUEST_METHOD']=='POST') { $jobId = $_SESSION['current_job_id']; // prepare insert query $insert = $db->prepare("INSERT INTO ssm_equipment_order (job_id, equipment_id, equipment_quantity) VALUES (?,?,?) "); foreach ($_POST['equipmentId'] as $k => $eid) { if ($_POST['equipmentQty'][$k] > 0) { $data = [ $jobId, $eid, $_POST['equipmentQty'][$k] ] ; $insert->execute($data); } } }
  15. Try reading your own code. Go through it line by line and check the value of each variable after each line executes. Does it look right to you? (you should end up with 0, 1, 5) vales after executing line ----------------------------- wallet balance amount 3 3 5 if($wallet + $balance >= $amount) { 3 3 5 $wallet = (string)($wallet - $amount); -2 3 5 //}elseif $wallet = 0; { $balance = ($balance - $amount); -2 -2 5
  16. try something like this $amount = 5; $wallet = 3; $balance = 3; if ($wallet >= $amount) { $wallet -= $amount; } elseif ($wallet + $balance >= $amount) { $amount_remain = $amount - $wallet; $wallet = 0; $balance -= $amount_remain; } else { echo "Insufficient funds<br>"; } echo "W: $wallet<br>B: $balance";
  17. You can use WHERE question_id IN (46, 47, 51)
  18. I find the easiest way to do these is to get the data you need then store in an array that is structured to match the required output. Then create your output from the array. DATA SELECT * FROM test.wp_lvsz_evr_attendee; SELECT * FROM test.wp_lvsz_evr_answer; +-----+-----------------+-------+-------+----------+ +-----------------+-------------+--------+ | id | registration_id | lname | fname | event_id | | registration_id | question_id | answer | +-----+-----------------+-------+-------+----------+ +-----------------+-------------+--------+ | 459 | 1 | Doe | John | 8 | | 1 | 40 | aaa | | 460 | 2 | Evans | Jane | 9 | | 1 | 41 | bbb | | 461 | 3 | Smith | Dave | 8 | | 1 | 42 | ccc | | 462 | 4 | Jones | Alec | 9 | | 1 | 43 | ddd | +-----+-----------------+-------+-------+----------+ | 2 | 40 | eee | | 2 | 41 | fff | | 2 | 42 | ggg | | 2 | 43 | hhh | | 3 | 40 | kkk | | 3 | 41 | mmm | | 3 | 42 | nnn | | 3 | 43 | ooo | | 4 | 40 | ppp | | 4 | 41 | qqq | | 4 | 42 | rrr | | 4 | 43 | sss | +-----------------+-------------+--------+ QUERY SELECT att.id , concat( lname, ' ', left( fname, 1 ) ) AS fullname , question_id , answer FROM wp_lvsz_evr_answer ans JOIN wp_lvsz_evr_attendee att ON att.registration_id = ans.registration_id AND question_id BETWEEN 41 AND 43; +-----+----------+-------------+--------+ | id | fullname | question_id | answer | +-----+----------+-------------+--------+ | 459 | Doe J | 41 | bbb | | 459 | Doe J | 42 | ccc | | 459 | Doe J | 43 | ddd | | 460 | Evans J | 41 | fff | | 460 | Evans J | 42 | ggg | | 460 | Evans J | 43 | hhh | | 461 | Smith D | 41 | mmm | | 461 | Smith D | 42 | nnn | | 461 | Smith D | 43 | ooo | | 462 | Jones A | 41 | qqq | | 462 | Jones A | 42 | rrr | | 462 | Jones A | 43 | sss | +-----+----------+-------------+--------+ CODE <?php $res = $db->query("SELECT att.id , concat( lname, ' ', left( fname, 1 ) ) AS fullname , question_id , answer FROM wp_lvsz_evr_answer ans JOIN wp_lvsz_evr_attendee att ON att.registration_id = ans.registration_id AND question_id BETWEEN 41 AND 43 "); $headings = [ 42 => 'Belt' , 43 => 'Event' , 41 => 'School' ]; $temp_array = array_fill_keys(array_keys($headings), ''); // array for each attendee to be filled in fro query results // process query results and place in array with attendee as the key $data = []; foreach ($res as $r) { if ( !isset($data[$r['id']])) { $data[$r['id']] = [ 'name' => $r['fullname'], 'answers' => $temp_array ] ; } $data[$r['id']]['answers'][$r['question_id']] = $r['answer'] ; // store answer in its array position } // now we can easily output the array into an html table $theads = "<tr><th>Name</th><th>" . join('</th><th>', $headings) . "</th></tr>\n"; $tdata = ''; foreach ($data as $att) { $tdata .= "<tr><td>{$att['name']}</td><td>" . join('</td><td>', $att['answers']) . "</td></tr>\n"; } ?> <table border='1' style='border-collapse: collapse; width: 600px'> <?=$theads?> <?=$tdata?> <?table> RESULT
  19. What are the table structures? I can't tell from your query which table all the relevant columns belong to.
  20. An insert will typically take hundredths of a second (depending on key complexity). If you are timing out you have a bigger problem. Check the connection, that's often the slower part.
  21. An error code perhaps?
  22. Regardless of that interpretation, the manual makes it clear what it does and when to use it, and you claim to have read that.
  23. @phpsane It really is a waste of our time replying to your posts, isn't it? Prior to your posting that solution, two people had told you that you don't need mysqli_stmt_free_result(), and why you don't need it. Yet, still, there it is.
  24. You could try finding out what the text actually contains (seems like there are no spaces) $text = wpjm_the_job_description(); $short = substr($text,0,25); // get first 25 characters $chrs = str_split($short); // split into individual chars $hex = array_map('bin2hex', $chrs); // get the hex values of those chars echo '<pre>', print_r($chrs, 1), '</pre>'; // output to compare echo '<pre>', print_r($hex, 1), '</pre>'; // output to compare What is the output?
  25. Try $text = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna. Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci. Aenean nec lorem."; $words = array_slice(explode(' ', $text), 0, 15); echo join(' ', $words) . '…';
×
×
  • 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.