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

problems with search form numerical "between" sending by php
I am trying to display the results of a search, on a sql database, on a web page. I set up html &quo

Set Categories
I am creating a submission form for somebody to come in and submit products. These products are sep

Please help with SMTP Authenticated PHP Email Form
Hello, I'm creating a PHP email form, and for this particular server, I have to use SMTP Authenticat

unexpected T_STRING
error log "[Sat Jan 09 18:27:58 2010] [error] [client 127.0.0.1] PHP Parse error: syntax error

Add User script "Could not execute query"
This should be an easy script but I can't get it to run. Can someone please help me?

<

generating random codes
Hi guys n gals,

I have a requirement to generate 250,000 unique codes...

These codes a

A WBS element with the name XXX already exists in version FREI_VERSION
Hi.
When I am trying to insert WBS element in a project, error occurs:

"A WBS eleme

please fix the error
What is the error in the below code ???
Line number On/Off | Expand/Contract <?php

Baffled by Undefined Index in Simple Array: Please Help!
Hello. I have a form which posts an array to this script. However, I can't seem to access the values

SuperCali PHP Event Calendar
does anyone have any experience with the SuperCali PHP Event Calendar? I could use some assistance

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