android6011 Posted April 11, 2008 Share Posted April 11, 2008 I know it seems like im flooding these forums with terrible questions, but I am going through some of my code and realizing that the coding is terrible :/ . If I want to get one field, like say age for a certain id number, what is the best method? Link to comment https://forums.phpfreaks.com/topic/100741-just-get-one-entry-from-table/ Share on other sites More sharing options...
soycharliente Posted April 12, 2008 Share Posted April 12, 2008 <?php $sql = "SELECT `age` FROM `table` WHERE `id`='$id'"; $result = mysql_query($sql) OR DIE (mysql_error()); if (mysql_num_rows($result)) { $row = mysql_fetch_assoc($result) { echo "<p>Your age is {$row['age']}!</p>"; } } else { // no rows returned but valid query } ?> Link to comment https://forums.phpfreaks.com/topic/100741-just-get-one-entry-from-table/#findComment-515282 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.