hackalive Posted March 29, 2010 Share Posted March 29, 2010 so I have code which gets all this db stuff, like a field called position now I need some code which will then add the value of position to a variable $AL$position{$id} while $AL is fixed $position needs to shift with the position so $AL1 is for position 1 and then an array {$id} with the id field filling that part ideas much appreciated Quote Link to comment https://forums.phpfreaks.com/topic/196863-for-or-while/ Share on other sites More sharing options...
hackalive Posted March 29, 2010 Author Share Posted March 29, 2010 ideas? Quote Link to comment https://forums.phpfreaks.com/topic/196863-for-or-while/#findComment-1033492 Share on other sites More sharing options...
hackalive Posted March 29, 2010 Author Share Posted March 29, 2010 let me know if I am trying to do the impossible and let me know a good alternative then Quote Link to comment https://forums.phpfreaks.com/topic/196863-for-or-while/#findComment-1033503 Share on other sites More sharing options...
hackalive Posted March 29, 2010 Author Share Posted March 29, 2010 someone must have an idea Quote Link to comment https://forums.phpfreaks.com/topic/196863-for-or-while/#findComment-1033860 Share on other sites More sharing options...
hackalive Posted March 30, 2010 Author Share Posted March 30, 2010 bump Quote Link to comment https://forums.phpfreaks.com/topic/196863-for-or-while/#findComment-1033914 Share on other sites More sharing options...
PFMaBiSmAd Posted March 30, 2010 Share Posted March 30, 2010 From the forum's rules - Users should not "bump" topics that are still on the first page of the forums. If you bump, you must provide additional information. If you resort to bumping, chances are your question needs to be re-thought and re-described Why don't you reread your first post in the thread and ask yourself if anyone can tell what you want. Perhaps if you posted an example showing variables, values, and what the expected result should be. Quote Link to comment https://forums.phpfreaks.com/topic/196863-for-or-while/#findComment-1033917 Share on other sites More sharing options...
hackalive Posted April 1, 2010 Author Share Posted April 1, 2010 anyone? Quote Link to comment https://forums.phpfreaks.com/topic/196863-for-or-while/#findComment-1035226 Share on other sites More sharing options...
salathe Posted April 1, 2010 Share Posted April 1, 2010 while $AL is fixed $position needs to shift with the position so $AL1 is for position 1 and then an array {$id} with the id field filling that part OK, given $position=1 and $id=99 you want to get/set $AL1[99] ? Quote Link to comment https://forums.phpfreaks.com/topic/196863-for-or-while/#findComment-1035228 Share on other sites More sharing options...
hackalive Posted April 1, 2010 Author Share Posted April 1, 2010 correct $AL1 is an 'array' which later I will implode Quote Link to comment https://forums.phpfreaks.com/topic/196863-for-or-while/#findComment-1035229 Share on other sites More sharing options...
salathe Posted April 1, 2010 Share Posted April 1, 2010 In that case: ${'AL'.$position}[$id] = 'blah' Quote Link to comment https://forums.phpfreaks.com/topic/196863-for-or-while/#findComment-1035230 Share on other sites More sharing options...
hackalive Posted April 1, 2010 Author Share Posted April 1, 2010 okay I'll give it a go thanks, i'll post again if it dosent work Quote Link to comment https://forums.phpfreaks.com/topic/196863-for-or-while/#findComment-1035231 Share on other sites More sharing options...
hackalive Posted April 1, 2010 Author Share Posted April 1, 2010 and this should do the implodes, but its not working $qry_AL = "SELECT max(position) FROM `articles` WHERE `uri`='$uri'"; $result_AL= $mysqli->query($qry_AL, MYSQLI_STORE_RESULT); $AL = mysqli_fetch_array($result_AL); $AL = $AL['0']; for($i=0;$i<=$AL;$i++) { $AL = $AL.$i; $AL.$i = implode("", $AL); } return $AL1; Quote Link to comment https://forums.phpfreaks.com/topic/196863-for-or-while/#findComment-1035246 Share on other sites More sharing options...
hackalive Posted April 1, 2010 Author Share Posted April 1, 2010 for($i=0;$i<=$AL;$i++) { $AL.$ii = implode("", $AL.$ii); } now replaces the previous equivelant, but it is still not working, it has something to do with that for part and its really annoying me. Basically what should happen is that $i is the maximum position value and then will implode all $AL# into just $AL# so if max position is 9 it should loop through doing the implode for $AL0, $AL1 etc upto and including $AL9, the $i should reflect the moving up value till $i=9 Quote Link to comment https://forums.phpfreaks.com/topic/196863-for-or-while/#findComment-1035253 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.