Jump to content

Barand

Moderators
  • Posts

    24,566
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. Is the div visible?
  2. I'm guessing you could also do it using SVG text.
  3. You removed the echo. It used to be echo json_encode($response); So it should still echo $response;
  4. Your PHP doesn't echo anything to go into the response (unless you have a query error).
  5. See my previous reply. AFAIK CSS doesn't support outline font-style so you may need to specify an outline font.
  6. If "Wno" in your table is the week number then use "... WHERE Wno BETWEEN 1 AND 13" in your query to get the first quarter and not rely on LIMIT
  7. Give us a clue - what exactly is reported as being "undefined"?
  8. You can't in PHP. You use CSS on the client. EG <html>> <head> <style type="text/css"> body { font-size: 24pt; } </style> </head> <body> <?php echo "Hello World";?> </body> </html>
  9. Why json_encode plain text? As you are already using jquery, why use getElementById() and not $('#ajaxDivOk').css("display", "block"); $('#ajaxDivOk').html("Registo(s) gravado(s) com sucesso");
  10. I can't see a reason for 1000+ writes in the code posted. Is that code inside another loop?
  11. What does $hora (or $_POST['hora']) contain?
  12. try $a = [1,2,3,4,5,6,7,8,9,10]; $b = [1,4,7,9,10]; $c = array_fill_keys(array_keys(array_diff($a,$b)),null) + $a; ksort($c); result: $c = Array ( [0] => 1 [1] => [2] => [3] => 4 [4] => [5] => [6] => 7 [7] => [8] => 9 [9] => 10 )
  13. Do you mean you can't access the keys of the outer array? $someArray = json_decode($newObject, true); foreach($someArray as $obj=>$value){ foreach ($value as $secondKey){ echo $obj . " " . $secondKey . "<br>"; } } gives firstObject red secondObject blue
  14. Ask MySql why. Add this line to the above code if (!$result) die(mysql_error()); Note that mysql_ functions are deprecated - you should be using mysqli or PDO functions
  15. try SELECT name FROM info i INNER JOIN files f ON f.parent = i.id GROUP BY name HAVING COUNT(f.fileid) < 3
  16. Instead of naming them "textarea1", "textarea2" etc, name them "textarea[]" so they are posted as an array. To process foreach ($_POST['textarea'] as $text) { // process each $text item }
  17. Not very helpful. I'm out.
  18. And we don't have the knowledge of what your $questions variable contains. Post the output from var_export($questions);
  19. When you use switch(TRUE) then the first case statement that evaluates to true (non-blank) will be used. You probably want switch ($events[0]) {
  20. Definition Test data : that data for which the program works. Your solution loops through the values in the three arrays and counts the occurrence of each value. If the occurrence is >2 it assumes it is a value common common to the three arrays. If however an array contained repeating values that would also appear as "common" in the solution EG in $array1 = [1, 5, 5, 10, 20, 40, 80]; $array2 = [5, 6, 6, 6, 7, 20, 80, 100]; $array3 = [3, 4, 15, 20, 30, 70, 80, 120]; 5 and 6 would also be wrongly included in the $commonValues array
  21. Use array_intersect $array1 = [1, 5, 10, 20, 40, 80]; $array2 = [6, 7, 20, 80, 100]; $array3 = [3, 4, 15, 20, 30, 70, 80, 120]; $common = array_intersect($array1, array_intersect($array2,$array3)); echo "Common values are " . join(', ', $common); //--> 20, 80
  22. Postcode is the common key between the two tables. It is the PRIMARY key in the postcode table and a FOREIGN key in each user record. That is how relational databases work. I suggested a postcode table with lat and long as these can be downloaded from the internet. Lat and Long would be FLOAT type.
  23. Instead of the sort you could find the highest value with max($all)
  24. Something like this, perhaps, assuming a postcode table ( postcode | latitude | longitude ) // Me and my latitude and longitude $myId = 123; $mylat = 54.123456; $mylong = -2.345678; // Find users within what distance? $target = 25; $sql = "SELECT name , latitude , longitude , ROUND(ATAN2(SQRT(POW(COS(RADIANS($mylat)) * SIN(RADIANS(longitude - $mylong)), 2) + POW(COS(RADIANS(latitude)) * SIN(RADIANS($mylat)) - SIN(RADIANS(latitude)) * COS(RADIANS($mylat)) * COS(RADIANS(longitude - $mylong)), 2)), (SIN(RADIANS(latitude)) * SIN(RADIANS($mylat)) + COS(RADIANS(latitude)) * COS(RADIANS($mylat)) * COS(RADIANS(longitude - $mylong)))) * 6372.795,0) as distance FROM user INNER JOIN postcode USING (postcode) WHERE userid <> $myId HAVING distance <= $target ORDER BY distance ";
  25. You haven't yet told us what you are trying to achieve, except you are calculating distances. From where to where?
×
×
  • 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.