how to update field pubilish by id Help me - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: how to update field pubilish by id Help me (/showthread.php?tid=58997) |
how to update field pubilish by id Help me - El Forum - 08-12-2013 [eluser]Unknown[/eluser] Hi guy! I want change php to codeigniter, Can help me I've table category, fields cate_id(int) , cate_name(varchar) and publish(bit) i want And here my code php $id = $_GET['cate_id']; $sql ="select * from comment where cate_id= $id order by cate_id"; $query = mysql_query($sql) or die (mysql_error()); $row = mysql_fetch_array($query); if($row['publish'] == 0) { $publish = $row['publish'] + 1; $sql_on = "update comment set publish = '$publish' where cate_id=$id"; $query_on = mysql_query($sql_on) or die (mysql_error()); } else { $publish = $row['publish'] - 1; $sql_off = "update comment set publish = '$publish' where cate_id=$id"; $query_off = mysql_query($sql_off) or die (mysql_error()); } Thank guy! how to update field pubilish by id Help me - El Forum - 08-13-2013 [eluser]jairoh_[/eluser] http://www.ellislab.com/codeigniter/user-guide/database/examples.html |