| In a loop like following, the variables can be accessed outside the loop but only under the loop. I want to access those variables above the loop. Is it possible?
$scoresql = "SELECT * FROM quizscore WHERE user_id=" . $_GET['id'] . ";"; $scoreresult = mysql_query($scoresql); while($scorerow = mysql_fetch_assoc($scoreresult)){ // Variables } |
|
| copas dari phpmyadmin.. |
|
| Mr. Shah Nawaz , Sukwinder Jit Singh said, why double ";"; ? is it true ?? |
|
| what I read here.. You want to see the first value/loop data>?? |
|
| Gunawan, if I use the variable after the loop, it works! but if I use the variable before the loop, it gives "Notice: Undefined variable:" error! |
|
| you can erase the error by use error_reporting(1); or just give the variable before mysql_query() |
|
| Gunawan, it's not only about the error... The variable has no value... If I use it below or inside the while loop, it has the value. |
|
| to have the value. you must type $scorerow = mysql_fetch_assoc($scoreresult) first |
|
| Would you like to see my code? |
Tidak ada komentar:
Posting Komentar