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 Link to comment https://forums.phpfreaks.com/topic/17140-need-help/ Share on other sites More sharing options...
brown2005 Posted August 10, 2006 Share Posted August 10, 2006 looks good to me Link to comment https://forums.phpfreaks.com/topic/17140-need-help/#findComment-72517 Share on other sites More sharing options...
desithugg Posted August 10, 2006 Author Share Posted August 10, 2006 any 1 else have any ideas? Link to comment https://forums.phpfreaks.com/topic/17140-need-help/#findComment-72565 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. Link to comment https://forums.phpfreaks.com/topic/17140-need-help/#findComment-72567 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. Link to comment https://forums.phpfreaks.com/topic/17140-need-help/#findComment-72568 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. Link to comment https://forums.phpfreaks.com/topic/17140-need-help/#findComment-72578 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 Link to comment https://forums.phpfreaks.com/topic/17140-need-help/#findComment-72579 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. Link to comment https://forums.phpfreaks.com/topic/17140-need-help/#findComment-72587 Share on other sites More sharing options...
SieRobin Posted August 10, 2006 Share Posted August 10, 2006 What are you trying to do desithugg? Link to comment https://forums.phpfreaks.com/topic/17140-need-help/#findComment-72588 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.