Question : update row information php

I have two columns, one is the Starting _Value and the other is the Current_Value.  I would like for the Current_Value data to copy over to the Starting_Value field in that same row.  
The problem with the current code is it is copying the data from the first Current_Value field and giving that data to all the Starting_Value fields throughout the database.


<?php
include_once "connect_to_mysql.php";

$sql = mysql_query("SELECT Current_Value FROM stock_index");
    $res = mysql_query($sql) or die(mysql_error());
      $totcal = mysql_fetch_assoc($res);

//$results = mysql_query($sql) or die(mysql_error());
$sql2 = "UPDATE stock_index SET Starting_Value='".$totcal['Current_Value']."'";
      $res = mysql_query($sql2) or die(mysql_error());
?>

Answer : update row information php

well that's easy...

$sql = "SELECT Current_Value, id FROM stock_index";
    $result = mysql_query($sql) or die(mysql_error());
    while ($row = mysql_fetch_array($result)){
        $current_value = $row[0];
        $id = $row[1];
        $sql2 = "UPDATE stock_index SET stock_index SET Starting_Value= "$current_value" WHERE id = $id"
        $res = mysql_query($sql2) or die(mysql_error());
    }
Random Solutions  
 
programming4us programming4us