Jump to content

mysql_fetch_array()


hoachen

Recommended Posts

New to php/mysql and hope someone will give me some opinion!I am trying to write a simple query using php/mysql. I am trying to select all the data from the database and echo them out so i can see the result.I know when use the mysql->Select * from tablename then we can see all the result on the table, but now, i am need to list all the field on my database to see the a row result like doing $rs['id'],.$rs['fname'],..... HOw can I not list all the fields to get the entire row data from the database? Please below code.$query = 'SELECT * FROM mailing_user';$result = mysql_query($query) or die('Query failed: ' . mysql_error());while($rs=mysql_fetch_array($result)){echo $rs['id'].$rs['fname'].$rs['lname']".<br/>";}

Link to comment
Share on other sites

New to php/mysql and hope someone will give me some opinion!I am trying to write a simple query using php/mysql. I am trying to select all the data from the database and echo them out so i can see the result.I know when use the mysql->Select * from tablename then we can see all the result on the table, but now, i am need to list all the field on my database to see the a row result like doing $rs['id'],.$rs['fname'],..... HOw can I not list all the fields to get the entire row data from the database? Please below code.$query = 'SELECT * FROM mailing_user';$result = mysql_query($query) or die('Query failed: ' . mysql_error());while($rs=mysql_fetch_array($result)){echo $rs['id'].$rs['fname'].$rs['lname']".<br/>";}

Check out this website:http://www.freewebmasterhelp.com/tutorials/phpmysql/1Part 4 and 5 look like they will help you out. If you need any explanation about the code PM me.
Link to comment
Share on other sites

You might also want to do this, if this is what you're asking:

while($rs=mysql_fetch_assoc($result)){  foreach ($rs as $fieldname => $value)  {    echo "{$fieldname}: '{$value}'<br />";  }  echo "<hr />";}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...