3 Replies - 1521 Views - Last Post: 08 March 2002 - 03:02 PM Rate Topic: -----

#1 Quik  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2
  • View blog
  • Posts: 3,750
  • Joined: 06-March 01

variables.. and more variables.

Posted 08 March 2002 - 01:13 PM

So, I planned this all out, and most would think this would work fine..
I have 20 name fields, all which have a name of "NAME1" , "NAME2" , "NAME3" etc.
Now,
In the action page I want to echo all  theese. I would think it would work as so:

$x = 1;
while($x <= 20){
echo "$name$x";
$x++
}

But after, I relized php parses variable by variable. So its saying
echo $name  and also $x

My question is, how would i combine two variables? or link them so it parses it as 1.

Of course, i could always echo $name1 $name2 $name3 but thats sloppy. There must be a way!


Is This A Good Question/Topic? 0
  • +

Replies To: variables.. and more variables.

#2 LammaDog  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 114
  • Joined: 30-September 01

Re: variables.. and more variables.

Posted 08 March 2002 - 01:23 PM

use an array
$name[$x]
Was This Post Helpful? 0
  • +
  • -

#3 Quik  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2
  • View blog
  • Posts: 3,750
  • Joined: 06-March 01

Re: variables.. and more variables.

Posted 08 March 2002 - 01:56 PM

dosnt work. :o
Was This Post Helpful? 0
  • +
  • -

#4 LammaDog  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 114
  • Joined: 30-September 01

Re: variables.. and more variables.

Posted 08 March 2002 - 03:02 PM

http://lammadog.com/...yan/Noname1.php

<?
if($parse == "yes")
{
for($x = 1; $x <= 20; $x++)
{
echo $artist[$x];
echo $song[$x];
}
exit;
}
?>

<html>
<body>
<form name="form1" method="post" action="?parse=yes">
<input type="text" name="week">
<table width="73%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="4%">#</td>
<td width="11%">Group</td>
<td width="85%">Song</td>
</tr>


<?
for ($x=1; $x <= 20; $x++ )
{
echo "
<tr>
<td width=4%>$x</td>
<td width=11%>
<input type=text name=artist[$x]>
</td>
<td width=85%>
<input type=text name=song[$x]>
</td>
</tr>";
}

?>

</table>
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1