Update Statement PHP-MYSQL

Discussion in 'PHP' started by vijaykoul, Aug 26, 2005.

  1. #1
    Hi frnds,

    i wud like to perform multiple updates in a single go in php.
    i have put the update statement in a for loop.
    but it gets executed only once.
    the code for the updation is:

    <?
    require("util.php");
    $sql=new MySQL_class;
    $sql->Create("direcsol");
    ?>
    <html>

    <head>
    <title></title>
    </head>

    <body>

    <?php

    $sql->Query("select * from idx_category_path");

    for($i=0; $i<$sql->rows; $i++)
    {
    $sql->fetch($i);
    $ifd=$sql->data["category_id"];
    $pth=$sql->data["path_with_url"];
    $fin=str_replace("-","/",$pth);
    $pst=str_replace("browse/","",$fin);
    $sql->query("update idx_category_path set path_with_url = '$pst' where category_id = '$ifd' ");
    }
    ?>
    </body>

    </html>



    "util.php" is a file which contains all the database connectivity functions.
    is there any problem with the above mentioned code.

    if there is one please suggest.

    thanks in advance

    Vijay Koul
     
    vijaykoul, Aug 26, 2005 IP
  2. Connect

    Connect Guest

    Messages:
    191
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Maybe you can try this:

    
    $bla = sql->rows;
    
    for($i=0; $i<$bla; $i++) {
    ...
    ...
    
    PHP:
     
    Connect, Aug 26, 2005 IP