Hey all,
I am having a little problem....I am using a piece of code similar to this:
more code.....
$query = mysql_query("SELECT * FROM table ORDER BY id");
while($row = mysql_fetch_array($query))
{
include("file.inc.php");
}
more code.....
now ..in file.inc.php I call the while loop variables using for example
<? echo "$row[name]"; ?>
and this does not work....I've tried doing it a number of ways and it ither shows nothing or shows the variable names.
I am at a loss as I would assume this would work...
any help would be appriciated...not looking for a spoon feed or such...just an idea of how i may be able to fix it..
TIAthis probably won't work, but try it without the quotes.nope ... nothing shows up.
thanks for the reply tho =)mmkay..little update...i got it working now...apparently I had a small microscopic error in my code further up...
for the record, include without the quotes gives "Failed opening fileincphp" ..that being the filename with no periods.
hehe...so atchually u did help me after all there transmothra
thanks againactually, i was talking about the echo statement there at the end of your post. i'm 99% sure it wouldn't have been any help at all though tehe yup....I overlooked the fact the atchual sql query I was using was :
$var = $HTTP_GET_VARS[var];
......
....
....
$query = mysql_query("SELECT * FROM table WHERE cat='$var'");
and when testing it...apparently I foregot var= in the url I should probably add a test for that hm?lol...why have an include in the loop anyway? that could be very taxing on the server as it has to open that up everytime you loop. I wouldn't use it that way.
also Trans was right, you don't need " in an echo if all you are doing is echoing a variable.
echo $row["name"];
would have worked as well. also if you don't add some kind of quotes in that variable it will fail.
so see what I did, tha tis fine, but you could also do this
echo $row['name'];
but I have seen that fail as well so I always use " in mine. if you do this
echo $row[name];
it will have the chance that it will be empty.well....I just did it that way because it happened to be the first functional way I thought of...alot of the code I'm writing right now will need a re-write.the point of the include is to display whats included everytime the loop loops.inside the includes are calls to the loop vars in how I want them displayed.I havn't given much thought about it 'should' be done,I'm sure if I did I couldeve found a better way(read: wouldeve found a better way).
As for the variable quoting...I wasn't aware that using an array variable without quotes could fail....thanks for pointing that out,will definitly fix that.
I am having a little problem....I am using a piece of code similar to this:
more code.....
$query = mysql_query("SELECT * FROM table ORDER BY id");
while($row = mysql_fetch_array($query))
{
include("file.inc.php");
}
more code.....
now ..in file.inc.php I call the while loop variables using for example
<? echo "$row[name]"; ?>
and this does not work....I've tried doing it a number of ways and it ither shows nothing or shows the variable names.
I am at a loss as I would assume this would work...
any help would be appriciated...not looking for a spoon feed or such...just an idea of how i may be able to fix it..
TIAthis probably won't work, but try it without the quotes.nope ... nothing shows up.
thanks for the reply tho =)mmkay..little update...i got it working now...apparently I had a small microscopic error in my code further up...
for the record, include without the quotes gives "Failed opening fileincphp" ..that being the filename with no periods.
hehe...so atchually u did help me after all there transmothra
thanks againactually, i was talking about the echo statement there at the end of your post. i'm 99% sure it wouldn't have been any help at all though tehe yup....I overlooked the fact the atchual sql query I was using was :
$var = $HTTP_GET_VARS[var];
......
....
....
$query = mysql_query("SELECT * FROM table WHERE cat='$var'");
and when testing it...apparently I foregot var= in the url I should probably add a test for that hm?lol...why have an include in the loop anyway? that could be very taxing on the server as it has to open that up everytime you loop. I wouldn't use it that way.
also Trans was right, you don't need " in an echo if all you are doing is echoing a variable.
echo $row["name"];
would have worked as well. also if you don't add some kind of quotes in that variable it will fail.
so see what I did, tha tis fine, but you could also do this
echo $row['name'];
but I have seen that fail as well so I always use " in mine. if you do this
echo $row[name];
it will have the chance that it will be empty.well....I just did it that way because it happened to be the first functional way I thought of...alot of the code I'm writing right now will need a re-write.the point of the include is to display whats included everytime the loop loops.inside the includes are calls to the loop vars in how I want them displayed.I havn't given much thought about it 'should' be done,I'm sure if I did I couldeve found a better way(read: wouldeve found a better way).
As for the variable quoting...I wasn't aware that using an array variable without quotes could fail....thanks for pointing that out,will definitly fix that.