hoachen Posted June 28, 2006 Share Posted June 28, 2006 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 More sharing options...
bgallegos Posted June 28, 2006 Share Posted June 28, 2006 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/>";}<{POST_SNAPBACK}> 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 More sharing options...
justsomeguy Posted June 28, 2006 Share Posted June 28, 2006 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now