Jump to content

[SOLVED] mysql_fetch_row


gevensen

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.