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

TabControl Inside ListView Not Editing
Hello everybodyI have a ListView on my page. Inside the ListView I put a TabControl, cuz I want to p

how to put the 0-100 numbers into 1.txt and 100-200 into 2.txt ?
how to put the 0-100 numbers into 1.txt and 100-200 into 2.txt and so on 200-300 into file 3.txt ?

Preg_match unknown modifyer
Hello,

Im trying to write a little script for my forums i need to get the reply from my forum

Web Application Recipe
Hi Guys!

I am working with the Web Application recipes. I am currently working on the sen

Problem with a select distinct
I have a problema with a select distinct, I have the next sql:

select distinct a,b,c,d fr

Windows 7
Windows 7 default user account control worries experts. Corporate IT departments should be pleased w

setcookie and isset($_COOKIE(name)) seem very finnicky.
I'm currently playing around with a user system with login and registration. I'm trying to use cooki

Problem with Subscreen
Dear Experts ,
I am facing a problem with the subscreens. My senario is as follows :

Insert Failing.
Hey,
I am making a Sign up page for a website, but the insert query into the Database does not se

php forms and database navigatio
Hello,
I'm new to php and i'd like to post the following.
I have written code to get records f

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