Jump to content

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

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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