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

PHP/Database issue
My friend is helping me make a database where you go to a certain webpage of my site and the page wi

code help - pagination
Hi all, I have this code, basically a user logs into my site and they get this page.

The pro

BAPI BBP_INB_DELIVERY_CREATE - material number missing in delivery
Hi Experts,

I was able to successfully create an Inbound delivery with reference to a PO

styling a RadioButtonList
HiI need to have a radio button and close to it, its lable, then a space then another set of those.

Save cookie to DB
I'm working on a pixel tracking script for an incentive website and I need to use an ASP script to s

How to assign JS screen.width to ASP.Net variable
I've got this ASP.net routine that gets the cookie value of the screen width, but now I need to chan

PHP Function Page Advice
Hi All, I am quite new to PHP and Javascript but have written an Online Shop (Mainly for Fun and edu

Transferring session variables into MySQL
I am trying to transfer $_SESSION variables into MySQL. However there is an error in my MySQL statem

Last character removed
I have created a string from an array. I have inserted commas from my form values. I am trying to re

[RESOLVED] Socket/Port remains open after app crashes
I'm having this problem with a networked app in vb.net.

If the program exits normally the por

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