Jump to content

How to grab info from mysql ...


bsamson

Recommended Posts

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

//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);

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.