![]() |
newbie - what does this code mean?
Hi,
Warning I'm a total newbie at both php and any type of coding at all. I was hoping someone could explain a line of code in a for loop for a php/mysql tutorial that I I've been trying to do. The following is the loop: for ($i=0; $i< $nRows; $i++){ $row = mysql_fetch_array($qResult); $rString .="&ID".$i."=".$row['ID']."&visitor".$i."=".$row['visitor']."&time".$i."=".$row['time']."&comment".$i."=".$row['comment']; } echo $rString."&"; The part I don't fully grasp is: $rString .="&ID".$i."=".$row['ID']."&visitor".$i."=".$row['visitor']."&time".$i."=".$row['time']."&comment".$i."=".$row['comment']; } My guess is this formats the output and calls the variables that will display in the echo $rString."&"; I guess what I don't understand is partially syntax related. I understand that the stuff with $ in it are variables and the stuff in the [ ] refers to items in the array but I don't understand what the stuff with the ampersand is doing. Also why does the = sign have to be in quotes? Thanks. djscour |
Hey djscour,
Wow, that lines a bit of a mouthful isn't it, you could do with breaking it down if you're struggling PHP Code:
How is $rString being used, in terms of where else is it called in the script? Regarding the equal sign (=), $rString is being used to concatenate different variables into one string, the full output would look something like: Code:
&ID1=x&visitor1=x&time1=x&comment1=x |
Hey Flying Buddha (by the way cool name),
Thanks a lot for responding. That definitely helped me understand a bit more. That's precisely what the tutorial is doing - using a flash interface. Also thanks for the alternate way of writing out that code. It is way easier to read that way. DJScour |
| All times are GMT. The time now is 03:16 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0