Gruzin Posted January 24, 2007 Share Posted January 24, 2007 Hi guys,Just want to know what's the difference between [b]mysql_fetch_array[/b] and [b]mysql_fetch_assoc[/b]?Thanks,George Link to comment https://forums.phpfreaks.com/topic/35497-question-about-mysql_fetch/ Share on other sites More sharing options...
HuggieBear Posted January 24, 2007 Share Posted January 24, 2007 Have you read the manual, as this makes it pretty clear![b]mysql_fetch_array()[/b][quote]Fetch a result row as an associative array, a numeric array, or both[/quote][b]mysql_fetch_assoc()[/b][quote]Fetch a result row as an associative array[/quote]RegardsHuggie Link to comment https://forums.phpfreaks.com/topic/35497-question-about-mysql_fetch/#findComment-167949 Share on other sites More sharing options...
Gruzin Posted January 24, 2007 Author Share Posted January 24, 2007 Thanks Huggie,I will read the manual again...Actaually I have a simple mysql query, like this:[code]$sql = mysql_query("SELECT * FROM aid_poll_results WHERE id='17'");while($row = mysql_fetch_assoc($sql)){$opt1 = $row['1'];$opt2 = $row['2'];$opt3 = $row['3'];$opt4 = $row['4'];$opt5 = $row['5'];$opt6 = $row['6'];$opt7 = $row['7'];$opt8 = $row['8'];$opt9 = $row['9'];}[/code]above query fetches rows correctly, but this:[code]$sql = mysql_query("SELECT * FROM aid_poll_results WHERE id='17'");while($row = mysql_fetch_array($sql)){$opt1 = $row['1'];$opt2 = $row['2'];$opt3 = $row['3'];$opt4 = $row['4'];$opt5 = $row['5'];$opt6 = $row['6'];$opt7 = $row['7'];$opt8 = $row['8'];$opt9 = $row['9'];}[/code]this example fetches rows, omitting 1 row, I mean it does fetch the rows except firts one, and instead of it fetches id row... hope u understand me :)Thanks,George Link to comment https://forums.phpfreaks.com/topic/35497-question-about-mysql_fetch/#findComment-167958 Share on other sites More sharing options...
matto Posted January 24, 2007 Share Posted January 24, 2007 remember arrays always begin with zero[code]$opt1 = $row['0'];$opt2 = $row['1'];....and so on[/code] Link to comment https://forums.phpfreaks.com/topic/35497-question-about-mysql_fetch/#findComment-167966 Share on other sites More sharing options...
Gruzin Posted January 24, 2007 Author Share Posted January 24, 2007 Thanks man ;) it works with mysql_fetch_array as well! Link to comment https://forums.phpfreaks.com/topic/35497-question-about-mysql_fetch/#findComment-167976 Share on other sites More sharing options...
matto Posted January 24, 2007 Share Posted January 24, 2007 Glad to have helped. Remember to set this thread to resloved... ;) Link to comment https://forums.phpfreaks.com/topic/35497-question-about-mysql_fetch/#findComment-168508 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.