-
Posts
24,604 -
Joined
-
Last visited
-
Days Won
830
Everything posted by Barand
-
When you are lost and want directions, it helps if you tell us where you want to go to. Why don't you tell us what you are trying to do. So far you have only told us how you are trying to get there. There could well be a better route. (And perhaps explain what that magical $vehicle object is and where comes from - it just pops up from nowhere in your code)
-
Probably as much use as Galen is to today's medical practitioners
-
Good idea. Do you think we should have something like this ?
-
If all you want is a row of date headings and a single row of totals, using PIVOT seems like overkill. <?php $res = $con->query("SELECT pay_date , SUM(amount) as total FROM income GROUP BY pay_date "); $data = $res->fetchAll(); $heads = "<tr><td>" . join('</td><td>', array_column($data, 'pay_date')) . "</td></tr>\n"; $totals = "<tr><td>" . join('</td><td>', array_column($data, 'total')) . "</td></tr>\n"; ?> <table border='1'> <?=$heads?> <?=$totals?> </table>
-
Have a try with simple_html_dom class
-
Stop posting duplicates of this topic.
-
PHP - How to take an image from an array and save it to MYSQL?
Barand replied to Zorglub's topic in PHP Coding Help
The solution was to use the correct variable! -
How do you expect me to answer questions like that when we don't have clue about what you are really doing. All we have is an abstraction of your problem. I have no idea what "filters" you are applying to other tables in the query. I am talking only about filters tht apply to "order" in this case. I don't know for sure if it is - I can't run your queries and time them - but you can.
-
fetch and display json array data stored in database
Barand replied to michelle1404's topic in PHP Coding Help
Each json message appears to be in a separate row in the table. I don't understand what you mean by "how to separate each json message." Do you mean just adding breaks in the output... $l1 = $con->prepare("SELECT msg, title FROM messages ORDER BY id DESC limit 4"); $l1->execute(); $cntmsg = $l1->rowCount(); foreach($l1 as $r1) { $m1 = $r1['msg']; $someJSON = $m1; $someArray = json_decode($someJSON, true); $pr1 = $someArray["data"]["commsettings"]; foreach($pr1 as $MyIndex => $MyValue) { echo $MyValue["name"] . '<br>'; } echo '<hr>'; } giving -
PHP - How to take an image from an array and save it to MYSQL?
Barand replied to Zorglub's topic in PHP Coding Help
What does this output? echo '<pre>' . print_r($vehicle, 1) . '</pre>'; -
If you change the query to this $sql = "UPDATE users SET name = :name, email = :email, phone = :phone, address = :address, license_number = :license_number, position = :position, role = :role, submittedby = :submittedby, image = COALESCE(:image, image) WHERE id = :id "; then, if :image is NULL, the existing value will not be changed.
-
I'd be inclined to do all the filtering required on the order in the subquery, ensuring there is only one row per order otherwise it throws the pagination. For example, if I only wanted to report orders that had sold widgets or gizmos SELECT o.order_id , customer , p.name , p.quantity FROM ( SELECT DISTINCT o1.order_id , concat(firstname, ' ', lastname) as customer FROM oc_order o1 JOIN oc_order_product op ON o1.order_id = op.order_id AND op.name IN ( 'gizmo' , 'widget' ) ORDER BY order_id LIMIT 0, 2 -- <- paginate here ) o JOIN oc_order_product p USING (order_id); As for relative speeds of alternatives, benchmark them (example).
-
OOP point to array value inside of a stdClass Object
Barand replied to jaybo's topic in PHP Coding Help
-> for object properties [] for array keys So $response->data->result[0]->value -
OOP point to array value inside of a stdClass Object
Barand replied to jaybo's topic in PHP Coding Help
Agreed. You do realize that it's objects and not arrays? -
OOP point to array value inside of a stdClass Object
Barand replied to jaybo's topic in PHP Coding Help
What's wrong with using "0"?