View Full Version : variable problem

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

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

according to number of rows

$res_rows = mysql_num_rows($result3); // number of rows
while ($jo = mysql_fetch_array($result3))
$a = "addaddd".$n;
echo ''.$addaddd5.'<br>';

the result is



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



so plz i need ur help

10-22-2009, 04: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.