How to update column=php-variable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jea
    New Member
    • Jan 2007
    • 11

    How to update column=php-variable

    If i want to update a col called 'name' I write
    set name="jea"

    But can I do the following:
    $col="name";
    set $col='jea'

    ???
  • chathura86
    New Member
    • May 2007
    • 227

    #2
    yes you can do it

    Regards

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      Hey.

      Assuming, based on the syntax of your variable, that you are using PHP, then most certainly, yes.

      If should look more like:
      [code=php]<?php
      $col = 'myCol';
      $sql = "UPDATE `tbl` SET $col='stuff'";
      $result = mysql_query($sq l);
      // etc...
      ?>[/code]
      The query is just a string, so you can manipulate it in any way you see fit.

      Comment

      Working...