...

View Full Version : variable problem



john_zakaria
10-22-2009, 10:05 AM
the red color is the error

i made an SQL statement that stores the id's in variable named by

$addaddd1
$addaddd2
$addaddd3
according to number of rows





$res_rows = mysql_num_rows($result3); // number of rows
while ($jo = mysql_fetch_array($result3))
{
$a = "addaddd".$n;
$$a=$jo[0];
echo ''.$addaddd5.'<br>';
$n+=1;
}



the result is
$addaddd1=1

$addaddd2=3

$addaddd3=7


i want to use the variable addaddd in another statment to use a query where the id is equal to the variable so it will be cat_id=1
the second cat_id=3 and the third cat_id=7




for ($i=1 ; $i <= $res_rows ; $i++ )
{


$qryp2 = "SELECT a.cat_id as cat_id , a.category as category , b.folder_path AS folder_path , b.categ_id as categ_id , b.id as id , b.sub_category as sub_category FROM category a , sub_category b where a.cat_id= " . $addaddd.$i . " and a.cat_id = b.categ_id order by a.cat_id ASC";
}



i want the variable
a.cat_id=$addaddd1

a.cat_id=$addaddd3

a.cat_id=$addaddd7



so plz i need ur help

Fumigator
10-22-2009, 05:28 PM
Why would you not just use an array and reference an index in an array? Why do you require the variable name to be $addaddd appended with a number? Just use $addaddd[n], where 'n' is 1, 2, 3, etc.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum