Jump to content


Photo

Generate variable name


  • Please log in to reply
1 reply to this topic

#1 winnij

winnij
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 07 July 2006 - 06:51 AM

Hello,

For a website php and mysql are used. A recordset contains names and a filelocation.
Each name an each fillelocation needs to become a variable. I would achieve that by a for loop, see example.

for($i=0; $totalRows_RS-1 ; $i++){
($tab +($i+1)) = $row_RS['name'];
($link + ($i+1)) = $row_RS['location'];
}

PHP returns Parse error: parse error, unexpected '='..

Has anyone an idea to solve this problem?

#2 Zane

Zane
  • Administrators
  • Advanced Member
  • 4,134 posts

Posted 07 July 2006 - 09:24 AM

because you're using the wrong syntax

do this

${"tab".$i++} = $row_RS['name'];

btn_donate_SM.gif Want to thank me? Contribute to my PayPal piggy-bank
 

172938.png




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users