corsasport.co.uk
 

Corsa Sport » Message Board » Off Day » Geek Day » PHP Geeks....


New Topic

New Poll
  Subscribe | Add to Favourites

You are not logged in and may not post or reply to messages. Please log in or create a new account or mail us about fixing an existing one - register@corsasport.co.uk

There are also many more features available when you are logged in such as private messages, buddy list, location services, post search and more.


Author PHP Geeks....
Bart
Member

Registered: 19th Aug 02
Location: Midsomer Norton, Bristol Avon
User status: Offline
27th Apr 15 at 18:42   View User's Profile U2U Member Reply With Quote

I need to update a number of order totals within a DB and have been given this code to look at:

quote:

<?php
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;

$sql = "SELECT id FROM purchaseorder WHERE datecreated > DATE_SUB(CURDATE(), INTERVAL 2 YEAR)";
$result = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($result)) {
echo "Update Purchase Order: " . $row["id"] . "<br/>";
updatePurchaseOrderTotals($row["id"]);
}

$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$finish = $time;
$total_time = round(($finish - $start), 4);
echo 'Update Time : '.$total_time.' seconds.';
?>



Now im not a PHP/Coding person, but the above doesn't appear to be updating anything, from what I can see its searching for orders with a created date of a 2 year period and simply echo'ing them on the page.

Is that correct or have I mis-understood the code?

[Edited on 27-04-2015 by Bart]
Ian
Site Administrator

Avatar

Registered: 28th Aug 99
Location: Liverpool
User status: Online
27th Apr 15 at 18:45   View Garage View User's Profile U2U Member Reply With Quote

Yes although it is calling a function updatePurchaseOrderTotals() which may be doing more.
Dom
Member

Registered: 13th Sep 03
User status: Offline
27th Apr 15 at 19:45   View User's Profile U2U Member Reply With Quote

As Ian has mentioned, you need to look at the updatePurchaseOrderTotals() function to see what's actually being done with the query results.

 
New Topic

New Poll

  Related Threads Author Forum Replies Views Last Post
Nakamishi headunits NovaGTE Help Zone, Modification and ICE Advice 29 3079
26th Oct 05 at 10:37
by Fear
 
Corsa turbo Vs MR2 Rich_J_Williams General Chat 104 5418
3rd Apr 06 at 19:52
by Steve
 
Fones for sale for u geeks! Munchie Geek Day 0 664
22nd Jun 06 at 11:26
by Munchie
 
geeks do you want a new dell 20" LCD screen? SetH Geek Day 5 829
27th Dec 06 at 14:10
by Jamie Walby
 
PHP/HTML Geeks... Bart Geek Day 24 1094
28th Mar 12 at 15:43
by Dom
 

Corsa Sport » Message Board » Off Day » Geek Day » PHP Geeks.... 29 database queries in 0.0060132 seconds