bsamson Posted September 4, 2007 Share Posted September 4, 2007 Hello, Here's the situation. I have a table w/ 1 entry w/ only 3 fields ID | password | update 01 | blahblah | 09/01/2007 I just want to grab the password and update from that. This is how I am currently doing it (please dont laugh) $query = "SELECT * FROM incpassword"; $result = mysql_query($query); while ($row=mysql_fetch_array($result)) { $grabpswd = $row['password']; $grabdate = $row['update']; } Is there an easier way to assign a variable to those 2 values w/o having to use while. Especially considering there is only 1 entry and only 3 fields. Thanks in advance for any assistance! --Brian Link to comment https://forums.phpfreaks.com/topic/67901-how-to-grab-info-from-mysql/ Share on other sites More sharing options...
micah1701 Posted September 4, 2007 Share Posted September 4, 2007 //best method: $result = mysql_query("SELECT * FROM incpassword"); $row = mysql_fetch_assoc($result); $grabpswd = $row['password']; $grabdate = $row['update']; -- OR -- $result = mysql_query("SELECT password,update FROM incpassword"); $grabpswd = mysql_result($result,0,0); $grabdate = mysql_result($result,0,1); Link to comment https://forums.phpfreaks.com/topic/67901-how-to-grab-info-from-mysql/#findComment-341287 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.