Moderators mark1million Posted September 15, 2011 Moderators Report Posted September 15, 2011 HI, I have been messing about for a few days not but cant seem to get the right code. I want to update a the pireps table flighttype field where flightnum = T1%% that's not important but i cant get it to run. Basically i have tours that i have now created a separate flighttype for, at the moment they are all in there as P for passenger flights, i want to update them to T for tours as im now reporting in the profiles flight types. Any help would be appreciated. Slightly going mad with banging my head against a wall Quote
Guest lorathon Posted September 15, 2011 Report Posted September 15, 2011 try $sql = 'SELECT * FROM '.TABLE_PREFIX.'pireps where flightnum = \'T1%\' '; $ret = DB::get_results($sql); Quote
Guest lorathon Posted September 15, 2011 Report Posted September 15, 2011 and then if that works you can loop through $sql = 'SELECT * FROM '.TABLE_PREFIX.'pireps where flightnum = \'T1%\' '; $pireps = DB::get_results($sql); foreach($pireps as $pirep) { $fields = array('flighttype' => 'T'); PIREPData::updatePIREPfields($pirep->pirepid, $fields); } Quote
Moderators mark1million Posted September 15, 2011 Author Moderators Report Posted September 15, 2011 Ah no i have the correct output its just i need to update the database, i ran a query and reset the flighttypes all to P lol. oops Im in phpmyadmin trying to run the query to manually update the entries. Quote
Guest lorathon Posted September 15, 2011 Report Posted September 15, 2011 Will this work? NOT TESTED. I would copy the pireps table to a backup and play with that one. Don't want to screw up the original. UPDATE phpvms_pireps SET `flighttype` = `T` WHERE `flightnum` = `T1%` Quote
Moderators mark1million Posted September 15, 2011 Author Moderators Report Posted September 15, 2011 Thanks Jeff I have already duplicated that table to play with, will give that a go in a bit. Quote
Moderators mark1million Posted September 15, 2011 Author Moderators Report Posted September 15, 2011 Same thinig for some reason im getting #1054 - Unknown column 'T1L%' in 'where clause' Wall :--( bang lol The damn thing does exist. Quote
Guest lorathon Posted September 15, 2011 Report Posted September 15, 2011 Try this. Different quotes plus LIKE instead of = UPDATE phpvms_pireps SET `flighttype` = 'T' WHERE `flightnum` LIKE 'T1%' Quote
Moderators mark1million Posted September 15, 2011 Author Moderators Report Posted September 15, 2011 Jeff this is driving me crazy lol, I now have it working with just a minor adjustment UPDATE phpvms_pireps SET `flighttype` = 'T' WHERE `flightnum` LIKE 'T1L%' Had to replace the `T` with 'T' I hate sql lol Thank you for your help. Quote
Guest lorathon Posted September 15, 2011 Report Posted September 15, 2011 LOL.. Glad you got it working. Quote
Moderators mark1million Posted September 15, 2011 Author Moderators Report Posted September 15, 2011 Thanks again Jeff this was driving me mad. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.