Please help me convert this php to CI code - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Please help me convert this php to CI code (/showthread.php?tid=19016) Pages:
1
2
|
Please help me convert this php to CI code - El Forum - 05-25-2009 [eluser]Jbeasley6651[/eluser] $listingCounter = 1; foreach ($updateRecordsArray as $recordIDValue) { $query = "UPDATE records SET recordListingID = " . $listingCounter . " WHERE recordID = " . $recordIDValue; mysql_query($query) or die('Error, insert query failed'); $listingCounter = $listingCounter + 1; } I'm use to CAKE as a framework and i'm still learning CI have stand alone php/ajax code that works fine and i really need help converting it to code igniter. I'm placing this inside a controller (i'm opting out of models at the moment). For cake it would be something like... foreach ($updateRecordsArray as $recordIDValue) { $this->Record->id = $recordIdValue; $this->Record->saveField('recordListingID', $listingCounter); } Please help me convert this php to CI code - El Forum - 05-25-2009 [eluser]xwero[/eluser] Code: foreach ($updateRecordsArray as $listingCounter=>$recordIDValue) { Please help me convert this php to CI code - El Forum - 05-25-2009 [eluser]Jbeasley6651[/eluser] i'm getting the error in my firebug console - A Database Error Occurred You must set the database table to be used with your query. Any Ideas? Please help me convert this php to CI code - El Forum - 05-25-2009 [eluser]Jbeasley6651[/eluser] How in your code would i set the table name where the data is being sent? Also, thanks for the fast response, i appreciate it alot. CI is amazing Please help me convert this php to CI code - El Forum - 05-25-2009 [eluser]Dam1an[/eluser] You can set it as a paramter for the update function, see the user guide for more info on updateing (and AR in general) Please help me convert this php to CI code - El Forum - 05-25-2009 [eluser]xwero[/eluser] oops i forgot that, i'm sorry Please help me convert this php to CI code - El Forum - 05-25-2009 [eluser]Dam1an[/eluser] Wow, even the likes of xwero make mistakes Please help me convert this php to CI code - El Forum - 05-25-2009 [eluser]TheFuzzy0ne[/eluser] I blame the government. Please help me convert this php to CI code - El Forum - 05-25-2009 [eluser]Jbeasley6651[/eluser] Got it! Thanks! To show how thankful I am heres a little treat for you. Have you ever wanted to drag and drop sort a list item? If anyone wants to do Ajax sortable list item (so you can drag and drop the list items to change order) and have it save to a database automatically upon dropping without refreshing the page in Code Igniter you can download the following... Screen Shots Before Drag <a href="http://img20.imageshack.us/img20/7101/picture1lfe.png">http://img20.imageshack.us/img20/7101/picture1lfe.png</a> During Drag <a href="http://img33.imageshack.us/img33/8241/picture2pxe.png">http://img33.imageshack.us/img33/8241/picture2pxe.png</a> After Drop (notice console data in firebug) <a href="http://img30.imageshack.us/img30/1791/picture3wxi.png">http://img30.imageshack.us/img30/1791/picture3wxi.png</a> Controller: Code: // Boxes Code: function updateBOX() CSS: Code: ul { JS/ajax- (you will need jquery draggable, droppable, sortable, selectable) Code: [removed] View: Code: <div id="contentLeft"> mysql dump: Code: CREATE TABLE `boxes` ( Please let me know if this was helpful. Thanks, Joel Beasley Please help me convert this php to CI code - El Forum - 05-25-2009 [eluser]xwero[/eluser] i blame the weather and a whole day of ASP.NET coding |