|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
While($row = mysql_fetch_array($result)) problem
I'm super new to PHP and im trying to just display all results from a certain table but its not working out @ all =(. I have different data in different tables, and I'm not exactly sure how to make it work? Any help is appreciated, also i know how terrible the code is so let loose. =P
function get_songs() { $conn = get_connection(); $query="SELECT * FROM songcontent ORDER BY date DESC"; $result=mysql_query($query); while($row = mysql_fetch_array($result)) { $songID = $row['songID']; $userID = $row['userID']; $query="SELECT songName FROM song WHERE songID='$songID'"; $result=mysql_query($query); $songName = $row[1]; $query="SELECT user FROM user WHERE id='userID'"; $result=mysql_query($query); $user=$row[0]; echo "$songName by $user"; } } |
|
#2
|
||||
|
||||
|
I'm not a PHP or MySQL expert, but from looking at the code the issue is that you reassign $result to a query that only returns a single row with the "Select songname ..." and Select user ..." queries.
I don't know the naming conventions but you should change the variable names. If you change the first one the others are fine. Perhaps something like: $query="SELECT * FROM songcontent ORDER BY date DESC"; $resultAll=mysql_query($query); while($row = mysql_fetch_array($resultAll)) { ... |
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > While($row = mysql_fetch_array($result)) problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|