473,320 Members | 1,719 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

PHP How do you update individual records based on WHERE condition?

12
I am updating records using a cron job that works perfectly fine. The issue I have is that the script is updating all records using the information from the first row matching my WHERE condition.

I'm using the following to query the database for data.

The row I'm searching for information from is time in the database, and mtime is a row that holds max time for the test.
Expand|Select|Wrap|Line Numbers
  1. $query = "SELECT * FROM info WHERE class = 'Math'";
  2. $data = mysqli_query($db, $query);
  3. $row = mysqli_fetch_array($data);
  4.  
  5. $time = 5;
  6. // Begin and IF statement to update the rows
  7. if ($row['time'] != $row['mtime']) {
  8.     $updatetime = $query = "UPDATE info set time=time+$time, WHERE class = 'Math'";
  9. } // Close If
So now what I want to be able to do is rather then having it only checking the mtime from the first row it pulls data from because each row has different mtime values. I would like to learn how to grab the first row check time vrs mtime update then move to the next record.

Thanks for all help ahead of time!
Jun 5 '10 #1
2 1504
HaLo2FrEeEk
404 256MB
I'm at work now, but when I get home I'll take a better look at this and see if I can help you out.
Jun 6 '10 #2
kadeous
12
I did it using a while loop, worked perfectly! TY though!!
Jun 6 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: M Wells | last post by:
Hi All, I have a database that is serving a web site with reasonably high traffiic. We're getting errors at certain points where processes are being locked. In particular, one of our people...
4
by: Mark S. | last post by:
Hi, I have a weird UPDATE sequence I want to perform. The customer does not want to use INSERT and DELETE. My issue is that there are multiple Mat_Class, but I do not wish to hard code each one...
8
by: xixi | last post by:
hi, we are using db2 udb v8.1 on windows, i have a table contains over one million records, it has seperate own tablespace than others, with bufferpool size 250, i have created multiple views on...
8
by: John Welch | last post by:
I have a command button with the following code: DoCmd.OpenForm "frmSearchAssignments", , , "SearchAssignmentID = 1" (SearchAssignmentID is the PK, auto number) When it runs, the form opens but...
2
by: Sreedhar Vankayala | last post by:
Hi, I have a table IV00108wc which contains several thousand records in whcih ITEMNMBR is the primary key. I have a com+ object returning recordset which has ITEMNMBR and another details...
3
by: Robert Fitzpatrick | last post by:
I have a view that used union all to merge three tables together. I was hoping to create a rule, one for each table using the WHERE condition of the rule to determine which table gets updated. Is...
0
by: lj | last post by:
How do I get an asp.net datagrid to set certain records as tedittemplate based on a certain condition. It is for a simple workflow. The user will have permission to see a list of records. He...
1
by: imtmub | last post by:
Hi, I am new to asp.net. I have single page website that display the recordsin gridview from sql table. The table has 4 fields (wood, woodsize, price & woodtype). and i have added Boundcolumn for...
6
by: BEETHOVEN | last post by:
I have an option group called Issue_Type on my main form F1_Member_Demographics_Main. When I select one of the 3 options on the main form from the option group Issue_Type I want to limit the sub...
0
by: micarl | last post by:
I'm trying to two two things through Access to Outlook based on a query and selections made on a form. Firstly, i'd like to create an email based on the selections made on a form. Secondly...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.