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' ";
Did you know?Explore Trending and Topic pages for more stories like this.
$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

Impact of movement type 412 E on MAP
Hi

Usage of movement type 412 E is causing huge change in MAP .

Is there any r

trim function issues
Hi guys, total noob here...

So I've been tinkering around with a html and am using php to em

Getting Resource id #11 while trying to connect..
So i tried using "DEFINE" for the first time and im using the variables i defined to conne

read integers that returns a negative or prints the average
Im trying to finish this homework assignment by tommarow afternoon and I keep getting stuck.
Wr

Why is this function returning a false value when it shouldn't be??
This is in an include file. I want it to check a value in an html form and see if it's just white s

Scrolling news bar and MySQL
I am not sure if this is the correct forum to post this on. If not, I apologize. I am still pretty

Strange HTML Tag?
I recently noticed some odd HTML appear in some of the websites I host. Not all of them are run on a

PHP Directory Listing Not working
Hey Guys,

I need help, I tried a ton of directory listing scripts and they all don't work. Al

Insert numbers from Barcode scanner into online php page
I have a real big problem, Here is what I'm trying to do. I have a Intermec CN3 handheld computer th

storing video files into mysql in php
hi

i have my video files in my folder ,
i have to store the path of the videos into db an

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