gevensen Posted September 23, 2009 Share Posted September 23, 2009 a question about mysql_fetch_row vs mysql_fetch_array i notice that on mysql_fetch_array i can specify MYSQL BOTH but that doesnt seem to work on mysql_fetch_row for example i would like it to show the row name such as $row['id'] not $row[0] am i doing something wrong or should i just use mysql_fetch_array for queries where i would like MYSQL BOTH Link to comment https://forums.phpfreaks.com/topic/175222-solved-mysql_fetch_row/ Share on other sites More sharing options...
gevensen Posted September 23, 2009 Author Share Posted September 23, 2009 i guess i should be using array mysql_fetch_assoc ( resource $result ) if i want the names added correct? Link to comment https://forums.phpfreaks.com/topic/175222-solved-mysql_fetch_row/#findComment-923524 Share on other sites More sharing options...
nuttycoder Posted September 23, 2009 Share Posted September 23, 2009 I would use mysql_fetch_object I prefer it its very simply to use, here's an example: <?php //connecto t db first $s = mysql_query("SELECT * FROM table")or die(mysql_error()); while($r = mysql_fetch_object($s)){ echo $r->columname; } ?> It returns the data as an object to get the data use -> then the name of the column, even works inside double quotes. Link to comment https://forums.phpfreaks.com/topic/175222-solved-mysql_fetch_row/#findComment-923656 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.