Take info from one coloum and move to another


Posted on 16th Feb 2014 07:03 pm by admin

Hi all,

I have this:
Code: [Select]$array = "SELECT stock_id FROM stocks WHERE stock_id BETWEEN '1' and '5' ";
$res = mysql_query($array);
$count = 0;
while ($row = mysql_fetch_assoc($res)){
if (is_int($count / 10) || $count == 0){
$rand_low = rand(1,5);
$rand_high = rand(1,5);
}
$num = rand($rand_low,$rand_high);
$update = "UPDATE stocks SET t_val=$num WHERE stock_id='" . $row['stock_id'] ."'";
if (mysql_query($update)){
echo "Updated record(s)<br />n";
}
}
Which simply updates a coloum called t_val with a random value between 1 and 5. I have another coloum in the table called y_val. What I would like to do is take the value of t_val before it is updated with the new rand and save it to the y_val coloum. How would I do this?

Many thanks

No comments posted yet

Your Answer:

Login to answer
104 Like 39 Dislike
Previous forums Next forums
Other forums

How to schedule the a job?
Hi,
I have prepared a task ( i.e. a procedure is prepare the file and send the same to con

(sub)screen resize modification doesn't work after ECC 6 EhP 4 installation
Hello,

We have previously extended the size of the custom data tab on PO transaction ME23

Record count of entire database
Does anyone know if there is a way to obtain the number of records in each table of the database usi

b+ tree
Hi
can every body help me about b+ tree ?(insert & delete)

Re-Order by ID Number
I have a cms set up for inputting an image, thumb, title, pdf, and eps. When input the database ass

str_replace help
Hey there,

I'm a PHP newb, I'm having troubles with the str_replace function. I want to clean

UL and LI Add Form
The idea I want here is when the user click on a character name from the drop down select bar at the

first few characters only
hi, does anyone know how to use PHP to take the first few words of a text and limit them? i have see

Limiting uploaded file type
Hi. First post here
I am working on a simple upload script, and I need it to limit the allowed f

Filtering an Array Based on Value
I have a very simple script set up that pulls data from a database and is output using this code:

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash