desithugg Posted August 10, 2006 Share Posted August 10, 2006 [code]$count = "0";$count++;$query = "update signup set slot = $count where username = '$user_currently_loged'"; $result = mysql_query($query);[/code]will this number the slots going up by 1 each time and theres a reason im not using suto incretment Quote Link to comment Share on other sites More sharing options...
brown2005 Posted August 10, 2006 Share Posted August 10, 2006 looks good to me Quote Link to comment Share on other sites More sharing options...
desithugg Posted August 10, 2006 Author Share Posted August 10, 2006 any 1 else have any ideas? Quote Link to comment Share on other sites More sharing options...
Orio Posted August 10, 2006 Share Posted August 10, 2006 Try changing the query to:$query = "update signup set slot='$count' where username='$user_currently_loged'";If that doesnt work, post the full code, maybe there's an error somewhere else.Orio. Quote Link to comment Share on other sites More sharing options...
desithugg Posted August 10, 2006 Author Share Posted August 10, 2006 [code]<?$count++; $query = "update items set slot = '$count' where trainer = '$user_currently_loged'"; $result = mysql_query($query);?>[/code]is the whole code and yess it is connected to the db it sets all slot rows as 1what i want to do is update all the items owned by a certain user and number the row "slot" in order starting from 1 and i cant auto incretement because i only want to do it for 1 user at a time and start over from 1 for every user sorry if im confusing but really stuck at this and Count++ wont work so im looking for more ideas. Quote Link to comment Share on other sites More sharing options...
Orio Posted August 10, 2006 Share Posted August 10, 2006 If it's the whole code, where the connection to the database? And why do you use a var, instead of directly making it a zero:[hr][code=php:0]//connect to DB$query = "update items set slot='0' where trainer = '$user_currently_loged'";$result = mysql_query($query);[/code][hr]Orio. Quote Link to comment Share on other sites More sharing options...
desithugg Posted August 10, 2006 Author Share Posted August 10, 2006 i dont want to make it zero i want to number them starting from 0 going up by 1 each time Quote Link to comment Share on other sites More sharing options...
Orio Posted August 10, 2006 Share Posted August 10, 2006 That's something totally diffrent from what you wrote...I made a script for you, but I am not sure if you can use LIMIT inside update and if it'll work like expected... Try and see:[code]<?php//connect to db here$query_a="SELECT * FROM `table` WHERE trainer = '$user_currently_loged'";$result_a=mysql_query($query_a);$num_rows=mysql_num_rows($result);$count=1;while($count<=$num_rows){$update="UPDATE `table` SET slot='".$count-1."' WHERE trainer = '$user_currently_loged' LIMIT ".$count.",1";$result=mysql_query($update);$count++;}?>[/code]I think it'll work :)Orio. Quote Link to comment Share on other sites More sharing options...
SieRobin Posted August 10, 2006 Share Posted August 10, 2006 What are you trying to do desithugg? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.