-
Posts
24,563 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
If you are having an apostrophe problem, like inserting surnames such as O'Reilly or O'Connell, then you are doing it wrong (such as not using prepared statements). It's not the fault of using AJAX.
-
Pure bovine ordure.
-
Even though mac_gyver has just told you how?
-
I get same result, with and without background image, in both Firefox and Chrome <head> <style type='text/css'> .test { width: 300px; height: 300px; margin: 50px; padding: 20px; background-color: black; background-image: url(caution_logo.jpg); background-repeat: no-repeat; background-position: center; background-size: 50%; border: 1px solid black; float: left; } .test2 { width: 300px; height: 300px; margin: 50px; padding: 20px; background-color: black; border: 1px solid black; float: left; } .curved-bottom { border-bottom-left-radius: 50%; border-bottom-right-radius: 50%; } </style> </head> <body> <div class='test curved-bottom'> </div> <div class='test2 curved-bottom'> </div> </body>
-
Adding a new group of fields onclick, not just one field
Barand replied to jasonc310771's topic in Javascript Help
I don't see the date format as a problem. A date type input field will use the client computer's date/time settings. So, whereas you and I will see 11/08/2023 displayed today, Requinix and the rest of his contrary compatriots will see it as 08/11/2023 if they display your form. In either case it will be sent in the form's data as 2023-08-11 to your PHP script. Make sure you use Y-m-d format for setting min, max and initial values. In addition, the drop-down calendar removes any ambiguity -
Adding a new group of fields onclick, not just one field
Barand replied to jasonc310771's topic in Javascript Help
Does it have to be a datepicker widget, or would an ordinary <input type='date'> be sufficient? -
Perhaps because you ignored Kicken's reply?
-
Why? $str = "The man from Del Monte, he said \"Yes!\""; $j = json_encode($str); echo $j . '<br>'; // "The man from Del Monte, he said \"Yes!\"" echo json_decode($j); // The man from Del Monte, he said "Yes!"
-
Alternative php solution $res = $pdo->query("SELECT id , name , month , field1 , field2 , field3 , field4 FROM senthil ORDER BY id "); $tdata = ''; foreach ($res as $r) { $flds = array_slice($r,3); foreach ($flds as $k => $v) { if ($v) { $tdata .= "<tr><td>{$r['name']}</td><td>{$r['month']}</td><td>$k</td></tr>\n"; } } }
-
If you had normalized your tables correctly you would already have the data in this format SELECT id , name , month , 'Field1' as field FROM senthil WHERE field1 = 1 UNION SELECT id , name , month , 'Field2' as field FROM senthil WHERE field2 = 1 UNION SELECT id , name , month , 'Field3' as field FROM senthil WHERE field3 = 1 UNION SELECT id , name , month , 'Field4' as field FROM senthil WHERE field4 = 1 ORDER BY id, field
-
One way... $str = "1 x MAKE: Behringer, 1 x MODEL: X-32, 1 x Problem with unit: Not powering on"; $a = explode(': ', $str); unset ($a[0]); foreach ($a as $b) { $results[] = explode(',', $b)[0]; } echo '<pre>results = ' . print_r($results, 1) . '</pre>'; output... results = Array ( [0] => Behringer [1] => X-32 [2] => Not powering on )
-
Best to use the third version... <form method="post"> PHP_SELF is vulnerable. Prepared statements protect against SQL injection attacks. There are still other types out there.
-
Google Column Chart data display month wise
Barand replied to Senthilkumar's topic in PHP Coding Help
Here's what I'd suggest then. Your new "Month" table will contain the month only (Jan, Feb etc with no year, we'll always assume the current year). Your query becomes SELECT mnth.Month , Revanue , EmployeeExpense , InfraExpense , OtherExpense FROM ( select id , concat(month, '-', YEAR(CURDATE())) as Month from dbms.month ) mnth LEFT JOIN ( select Month , sum(Revanue) as Revanue from dbms.revenue_data where dealerid = '81019218' AND Status = '1' group by Month ) revenue USING(Month) LEFT JOIN ( select Month , sum(Total) as EmployeeExpense from dbms.employeeexpense where dealerid = '81019218' AND Status = '1' group by Month ) EmployeeExpense USING(Month) LEFT JOIN ( select Month , sum(Total) as InfraExpense from dbms.infrastructure_expense where dealerid = '81019218' AND Status = '1' group by Month ) InfraExpense USING(Month) LEFT JOIN ( select Month , sum(Total) as OtherExpense from dbms.otherexpense where dealerid = '81019218' AND Status = '1' group by Month ) OtherExpense USING(Month) ORDER BY mnth.id; -
Google Column Chart data display month wise
Barand replied to Senthilkumar's topic in PHP Coding Help
So your tables don't store the actual date that the expense (or other transaction) occured? -
Google Column Chart data display month wise
Barand replied to Senthilkumar's topic in PHP Coding Help
What format? Show sample records. (This is like pulling teeth) -
Google Column Chart data display month wise
Barand replied to Senthilkumar's topic in PHP Coding Help
You answer my earlier questions about how you are storing the month/dates and I'll answer yours. -
Google Column Chart data display month wise
Barand replied to Senthilkumar's topic in PHP Coding Help
That's because you aren't selecting the id column in the mnth subquery. You can just use the FROM dbms.Month instead of that first subquery. -
Google Column Chart data display month wise
Barand replied to Senthilkumar's topic in PHP Coding Help
At the end to order the results. -
Google Column Chart data display month wise
Barand replied to Senthilkumar's topic in PHP Coding Help
If your Month table looks something like this +-----+--------------+ | id | Month | +-----+--------------+ | 1 | Jan-23 | | 2 | Feb-23 | | 3 | Mar-23 | | 4 | Apr-23 | | 5 | May-23 | | 6 | Jun-23 | | 7 | Jul-23 | | 8 | Aug-23 | | 9 | Sep-23 | | 10 | Oct-23 | | 11 | Nov-23 | | 12 | Dec-23 | +-----+--------------+ then you can ORDER BY mnth.id How are you storing Month in those tables? Do you have a separate column for actual transaction date? -
Google Column Chart data display month wise
Barand replied to Senthilkumar's topic in PHP Coding Help
Of course it is! How can you expect the results to contain data that isn't there? You can attack the problem from the input end or the output end of the process. Input method Create a temporary table `tempdate` (id , month) with 12 rows - one for each month - and left join the subqueries to this. Output method create an array with key for each month and store your result's totals in this array. Create chart from the array data. NOTE: If your Month column is datetime time (which it appears to be as you reformat using strtotime) your queries are are grouping and joining by day and not by month (unless you are always storing the first day of the month, which we can't see) -
JOIN outputs matches from both tables. Only 3 have a match in the other table. If you want all data records even when there is no matching target record then you need ... FROM data table LEFT JOIN target table
-
I would write it like this... function PrintCellProviders($CellProviders, $default_value=null) { $opts = ""; foreach ($CellProviders as $col_value) { $sel = $col_value == $default_value ? 'selected' : ''; $opts .= "<option $sel>$col_value</option>"; } return $opts; // return the options } without using GLOBAL but passing the array instead. Then, in the HTML <select name='cellProvider'> <?= PrintCellPrividers($CellProviders) ?> <!-- output the returned options --> </select>
-
I don't know how you are trying to use it. All we have is the function without any context. You were complaining that it returns no value...
-
Your function does not contain a "return" statement to tell it to return a value