Jump to content

for or while


hackalive

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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] ?

Link to comment
Share on other sites

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;

Link to comment
Share on other sites

	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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.