Jump to content

single cell query


atmoth

Recommended Posts

hello, i am trying to write a script that pulls one row of data from a database table and lists each cell of data in a different <td>. i have tried a few things such as mysql_result() but have had no luck. does anyone have any solutions to my problem?thanks,atmoth

Link to comment
Share on other sites

Hi!You could use mysql_fetch_assoc(), which basicaly is the same as mysql_fetch_array( $result, MYSQL_ASSOC ).

while ($row = mysql_fetch_assoc( $result )) {   echo "<tr>\n";   echo ' <td>'.$row['id']."</td>\n";   echo ' <td>'.$row["field1"]."</td>\n";   echo ' <td>'.$row["field2"]."</td>\n";}

If you just want one row, remove the while-statement, but keep

$row = mysql_fetch_assoc( $result )

Hope that helpedGood Luck and Don't Panic!

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...