...

View Full Version : Resolved Problem In Updating



darksecu
04-12-2012, 10:19 AM
Table name "cycles" This is how my table looks

http://i2.lulzimg.com/0c1eaa0f7b.jpg

I want to fetch the top user where line=1,2,3,4 so on , done by looping ..
then i want to update those users with line="line number +1" and percent column being updated by +10 ...

here the code i am trying ... working great but its not calculating the new line number properly..
it should update 1 to 2 , 2 to 3 , 5 to 6 and so on but its updating database line column with "1+1 , 2+1 , 5+1 and so on" text ..


$i=1;
while($i<=$csetting['line']){
$exist=mysql_num_rows(mysql_query("select * from cycles where line='$i'"));
if ($exist == '0') { $i++; } else {
$row=mysql_fetch_assoc(mysql_query("select * from cycles where deleted='0' and line='$i' order by id limit 0,1"));
$id=$row['id'];
$lines=$row['line'];
mysql_query("update cycles set line='$lines+1' where id=$id");
$i++; }
}

i think there is some problem in adding code ... please help me to fix it ..



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum