Jump to content

Barand

Moderators
  • Posts

    24,342
  • Joined

  • Last visited

  • Days Won

    795

Everything posted by Barand

  1. Unless that is the data in your articles record it looks as though you aren't getting the date either. Make sure you set the option to throw exceptions in your PDO connection and turn PHP error reporting on. Then come back.
  2. Are you getting the correct date for the record with that postID or is it always 1stJan 1970?
  3. Have you checked your "articles" data to ensure there is something in there other than the date?
  4. Either if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] == false) { header("Location: ../login.php"); } or use your function. if (!is_logged_in()) { header("Location:../login.php"); }
  5. F***** up beyond all recognition. If $_SESSION['loggedin'] is not set, it doesn't send them anywhere, the code only executes if it is set.
  6. and Do you know the difference between a database and a table? Is there a table called "licjwe" in your database?
  7. The index.php code that you posted doesn't show any checking. The admin/index.php code looks FUBAR, sending you to login.php if you are logged in. (and if you have gone to the trouble of writing an "is_logged_in()" function, why not use it.
  8. Which, in turn, had been previously suggested by me. ?
  9. This example puts each schoolname into a hidden div and then gets the new width of the div. If it is greater than the std div width (less padding) it reduces the font size. <?php $schools = [ 'School name one', 'schoolname one hundred and twenty one', 'schoolname one thousand one hundred and twenty one', 'schoolname one million one hundred thousand one hundred and twenty one' // too long ]; $output = ''; foreach ($schools as $name) { $output .= "<div class='school'>$name</div>" ; } ?> <!DOCTYPE html> <html> <head> <meta http-equiv="content-language" content="utf-8"> <title>test</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script type="text/javascript"> $().ready( function() { $(".school").each( function () { var name = $(this).html(); $("#tester").html(name); var wid = $("#tester").css("width"); if (parseInt(wid) > 380) { $(this).css("font-size", "9pt") } }) }) </script> <style type="text/css"> body { font-family: calibri; font-size: 12pt; } .school { width: 400px; padding: 10px; border: 1px solid gray; margin: 5px;} #tester { white-space: nowrap; display: inline-block; visibility: hidden; } </style> </head> <body> <div id='tester'></div> <?=$output?> </body> </html>
  10. Try var_dump($a) - that will show if there are superfluous spaces in $a
  11. That answers the question "where does $a come from?", however the question was "what does it contain?" If you echo $a, what do you get?
  12. Let's leave it to stackoverflow to to answer before we waste our time on you.
  13. What value does $a contain when this happens?
  14. ($a = 'one') assigns the value 'one' to $a then returns $a. ($a == 'one') returns true if $a is equal to 'one' and 'false' if it is not. Which do you think you need? As it can be only one of those values you should use if ($a == 'one') { echo 'POOR'; } elseif ($a == 'two') { echo 'GOOD'; } elseif ($a == 'three') { echo 'VERY GOOD'; } elseif ($a == 'four') { echo 'EXCELLENT'; } Alternative 1 switch ($a) { case 'one': echo 'POOR'; break; case 'two': echo 'GOOD'; break; case 'three': echo 'VERY GOOD'; break; case 'four': echo 'EXCELLENT'; break; } Alternative 2 $status = ['one' => 'POOR', 'two' => 'GOOD', 'three' => 'VERY GOOD', 'four' => 'EXCELLENT' ]; echo $status[$a];
  15. String literals in a query need to be in quotes. try $sql = "SELECT name FROM parts WHERE type='$list' "; EDIT: You should be using a prepared statement and not putting POSTed data directly into your query.
  16. 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>
  17. 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)
  18. 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
  19. 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>'; }
  20. Why is your table name variable? Do you have more than one? If so, why?
  21. 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)
  22. 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
  23. 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 | +----+---------------+
  24. You appear to be suffering from a sufeit of exuberance.
×
×
  • 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.