Jump to content

Barand

Moderators
  • Content Count

    19,206
  • Joined

  • Last visited

  • Days Won

    367

Everything posted by Barand

  1. Barand

    need some sound advice.

    This works for me <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Lang" content="en"> <title>Sample</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script type='text/javascript'> $().ready( function() { var url = "https://hpr.dogphilosophy.net/test/wav.wav"; var audio = new Audio(url); audio.type = 'audio/wav'; audio.play(); }) </script> </head> <body> Sound should be playing </body> </html>
  2. Barand

    Please help to optimize this query

    The sub-query will slow you down. The values in columns from products_sub and provider will be completely arbitrary as you are grouping by pcode (only one row per pcode in the output so values from those two table could come from any record with matching pcode) As you are selecting by status and ordering by status then try it with an index on product(status)
  3. Barand

    How can I align digit

    Or you can use printf() (as Benanamen suggested) between <pre>..</pre> tags echo '<pre>'; for ($i=0; $i<= 180; $i+=15) my_function2($i); echo '</pre>'; function my_function2($d) { printf("%4d ==> %0.6f\n", $d, deg2rad($d)) ; } 0 ==> 0.000000 15 ==> 0.261799 30 ==> 0.523599 45 ==> 0.785398 60 ==> 1.047198 75 ==> 1.308997 90 ==> 1.570796 105 ==> 1.832596 120 ==> 2.094395 135 ==> 2.356194 150 ==> 2.617994 165 ==> 2.879793 180 ==> 3.141593
  4. Barand

    How can I align digit

    Use right-aligned text for ($i=0; $i<= 180; $i+=15) my_function($i); function my_function($d) { echo "<div style='width: 30px; display:inline-block; text-align:right'>$d</div> ==> " . deg2rad($d) . '<br>'; }
  5. Barand

    Pull data to page based on id

    Why is your table name variable? Do you have more than one? If so, why?
  6. Barand

    Pull data to page based on id

    The above is the syntax for sprintf(), not prepare(). Secondly, since the query contains no user provided data parameters, a prepare is not required. (Note you cannot pass sql identifiers as parameters to a prepared statement)
  7. Does this example help? $json = '[{"a1":{"b":{"streamname":"bbbbbbbbbbbbbb","stream_id":123},"c":{"streamname":"ccccccc","stream_id":124}},"a2":{"d":{"streamname":"ddddddddddddd","stream_id":125},"e":{"streamname":"eeeeeeeeeeeee","stream_id":126}}},{"b1":{"b":{"streamname":"bbbbbbbbbbbbbb","stream_id":127},"c":{"streamname":"ccccccc","stream_id":128}},"b2":{"d":{"streamname":"ddddddddddddd","stream_id":129},"e":{"streamname":"eeeeeeeeeeeee","stream_id":130}}}]'; $data = json_decode($json, true); foreach ($data as $k1 => $data1) { foreach ($data1 as $k2 => $data2) { foreach ($data2 as $k3 => $data3) { echo "$k1 / $k2 / $k3 / {$data3['stream_id']} <br>"; } } } gives 0 / a1 / b / 123 0 / a1 / c / 124 0 / a2 / d / 125 0 / a2 / e / 126 1 / b1 / b / 127 1 / b1 / c / 128 1 / b2 / d / 129 1 / b2 / e / 130
  8. Barand

    How to create Dependent Dropdown List?

    You would make it a lot easier for yourself if the option values were sortable. At present they are not, giving five nine seven three You need to use ids as the values +----+---------------+ | Id | Name | +----+---------------+ | 1 | three_compact | | 2 | three_regular | | 3 | three_triple | | 4 | five_compact | | 5 | five_regular | | 6 | five_triple | | 7 | seven_compact | | 8 | seven_regular | | 9 | seven_triple | | 10 | nine_compact | | 11 | nine_regular | | 12 | nine_triple | +----+---------------+
  9. Barand

    Oh boi SQLSTATE[HY093] I Stuck

    You appear to be suffering from a sufeit of exuberance.
  10. Barand

    Pull data to page based on id

    P.S. That is if the method returns anything at all as you are using an obsolete mysql library that has been removed from PHP. Change to using PDO.
  11. Barand

    Pull data to page based on id

    It looks like $viewkudoid contains an id. $getthekudo contains a resultset returned by your function, not an array So if ($viewkudoid == viewkudoid['kudoid'] ) will always return false. However this is only guesswork as I have no way of knowing what your methods return.
  12. Barand

    Pull data to page based on id

    Then you know a lot more than we do. What is the issue?
  13. SELECT CASE WHEN home_score > away_score THEN home_id ELSE away_id END as winner FROM game;
  14. Why? If you know who's playing and the scores then you know the winner. (BTW, what if there is a draw?). Don't store derived data. The fixture date is good indicator of those played and those not yet played. try this echo '<table>'; $query_game = "SELECT team , DATE_FORMAT(gamedate, '%b %d') as date , TIME_FORMAT(gametime, '%l:%i %p') as time , home_score , away_score , winner , opponent , hora , gamedate -- required for date comparisons FROM ( SELECT h.schoolname as team , gamedate , gametime , home_score , away_score , winner , a.schoolname as opponent , 'h' as hora FROM a_games1920 g JOIN a_schools h ON g.home_id = h.id JOIN a_schools a ON g.away_id = a.id WHERE h.schoolname = '". $school ."' UNION ALL SELECT a.schoolname as team , gamedate , gametime , home_score , away_score , winner , h.schoolname as opponent , 'a' as hora FROM a_games1920 g JOIN a_schools a ON g.away_id = a.id JOIN a_schools h ON g.home_id = h.id WHERE a.schoolname = '".$school ."' ) x ORDER BY team, gamedate"; $result_game = mysqli_query($con,$query_game); echo mysqli_error($con); $prevdate = ''; $today = date('Y-m-d'); while($game = mysqli_fetch_assoc($result_game)) { // define home or away $hora = $game['hora']; if ($hora == 'h') { $hora = 'vs'; } else { $hora = '@'; } // Print the schedule if ($prevdate <= $today && $game['gamedate'] > $today) { // HAVE WE CHANGED TO FUTURE FIXTURES? echo "<tr><td colspan='3' style='background-color:black; color:white'>Future fixtures...</td></tr>\n"; $prevdate = $game['gamedate'] ; } echo '<div><tr><td>' . $game['date'] . '</td><td>'. $hora .' ' . $game['opponent'] . '</td>'; If (isset($game['winner'])) { if ($hora =='vs'){ echo '<td>' . $game['home_score'] . '-' . $game['away_score'] . '</td>'; } else { echo '<td>' . $game['away_score'] . '-' . $game['home_score'] . '</td>'; } } else { echo '<td>'. $game['time'] . '</td>'; } echo '</tr></div>'; } echo '</table>';
  15. ... which probably won't work if you are getting a blank page. You will need to catch any startup errors so the settings need to be in your php.ini file.
  16. Barand

    Oh boi SQLSTATE[HY093] I Stuck

    It's objecting to the number of parameters. Your query needs 3 you only provided 2. (You cannot re-use :f (you'll need :e, :f, :g) $sql = $this->Db->prepare("UPDATE ** SET data = CASE WHEN data IS NULL THEN :f ELSE (CONCAT(data,:g)) END WHERE lead=:e"); $sql->execute(array( ':e' => $data["lead"], ':f' => $data["comment"] . $data["text"], ':g' => $data["comment"] . $data["text"] ));
  17. Barand

    Echo Background Image Breaking site

    Try it without the <?php echo ... ?> You are already inside a php block of code echo "<article data-style='$label_style' style='background-image:url({$event->data->thumbnails['medium']})' class='mec-event-article mec-clear {$this->get_event_classes($event)} $colorful_bg_color>";
  18. Barand

    Oh boi SQLSTATE[HY093] I Stuck

    First thing to do is correct your case statement CASE WHEN data IS NULL THEN :f ELSE (CONCAT(data,:f)) END Check content of $data array.
  19. Barand

    Any obvious corrections?

    Your query didn't work.
  20. Query looks OK. I see the game table is named "a_games1920". How many game tables do have and do they all have a gametime column? Having a game table for each season is another of your bad ideas. You mentioned earlier about getting a coach's record over, say, the last 10 years. You will now have to query 10 different game tables to acclomplish that. All the games have a date so you know which seaon they belong to without adding another problem.
  21. Barand

    Need a dynamic Subform

    Use the forums code boxes (<> button on the toolbar) and stop posting black text on a black background.
  22. One thing you shouldn't do is run an outer query then loop through the results running further queries. It is inefficient and heavy on resources. You should use JOINS to get all the data you need in a single query
  23. What does $school contain?
  24. I am surprised you are getiing any results at all. Those where clauses should give only those matches where the home team and away team are the same team ($school) The first SELECT clause (home matches) should have "WHERE h.schoolname = '$school' " and the second should have "WHERE a.schoolname = '$school' " (Or use school_id , preferably)
×

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.