-
Posts
24,565 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
I'm guessing you could also do it using SVG text.
-
You removed the echo. It used to be echo json_encode($response); So it should still echo $response;
-
Your PHP doesn't echo anything to go into the response (unless you have a query error).
-
See my previous reply. AFAIK CSS doesn't support outline font-style so you may need to specify an outline font.
-
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
-
Replacing a select drop down with images in php
Barand replied to totallytech's topic in PHP Coding Help
Give us a clue - what exactly is reported as being "undefined"? -
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>
-
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");
-
I can't see a reason for 1000+ writes in the code posted. Is that code inside another loop?
-
What does $hora (or $_POST['hora']) contain?
-
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 )
-
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
-
How to search Punjabi regional language keyword in mysql
Barand replied to naresh_staplelogic's topic in MySQL Help
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 -
try SELECT name FROM info i INNER JOIN files f ON f.parent = i.id GROUP BY name HAVING COUNT(f.fileid) < 3
-
Form post, unknown number of fields to retrieve
Barand replied to jasonwisdom's topic in PHP Coding Help
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 } -
Displaying number of answered questions in an array.
Barand replied to ChrisWheeler's topic in PHP Coding Help
Not very helpful. I'm out. -
Displaying number of answered questions in an array.
Barand replied to ChrisWheeler's topic in PHP Coding Help
And we don't have the knowledge of what your $questions variable contains. Post the output from var_export($questions); -
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]) {
-
Getting a common value from 3 loops - help on understanding solution
Barand replied to coding_n00b's topic in PHP Coding Help
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 -
Getting a common value from 3 loops - help on understanding solution
Barand replied to coding_n00b's topic in PHP Coding Help
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 -
get new num_rows count after filtering mysqli_fetch_array rows via php
Barand replied to seany123's topic in PHP Coding Help
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. -
Do something with highest variable from an array of variables
Barand replied to peterhuynh's topic in PHP Coding Help
Instead of the sort you could find the highest value with max($all) -
get new num_rows count after filtering mysqli_fetch_array rows via php
Barand replied to seany123's topic in PHP Coding Help
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 "; -
get new num_rows count after filtering mysqli_fetch_array rows via php
Barand replied to seany123's topic in PHP Coding Help
You haven't yet told us what you are trying to achieve, except you are calculating distances. From where to where? -
get new num_rows count after filtering mysqli_fetch_array rows via php
Barand replied to seany123's topic in PHP Coding Help
If you were to store the lat and long of each user, or had a lookup table of lat and long by postcode, you could do the distance calculations in the query. This would be far mode efficient than accessing the google api for every record.