Jump to content

how can i declare a variable, that will contain part of another variable.


Orionsbelter

Recommended Posts

this is the actual code

<?php
for($i = 1; $i <= 6; $i++){
${'count'.$i} = mysql_query("SELECT `replies`, `id` FROM `topics` WHERE forumID='$i'");
${'numCount'.$i} = mysql_num_rows($count$i);
${'countTot'.$i} = 0;
while($row=mysql_fetch_array($count$i)){
	${'countTot'.$i}+=$row[0];
}
}
?>

 

and its coming up with Parse error: syntax error, unexpected T_VARIABLE in /home/www/golden8ball.co.uk/forums/index.php on line 3

http://php.net/manual/en/language.variables.variable.php

That said, you should look at arrays

http://php.net/manual/en/language.types.array.php

These are what smart programmers use :)

 

Why is it better for me to use the array() rather than for()??

 

 

http://php.net/manual/en/language.variables.variable.php

That said, you should look at arrays

http://php.net/manual/en/language.types.array.php

These are what smart programmers use :)

 

Why is it better for me to use the array() rather than for()??

 

 

 

That makes little sense. One creates a data structure, the other is a control structure.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.