# How can I Retrieve a record in mysql?

**URL:** <https://forum.kirupa.com/t/how-can-i-retrieve-a-record-in-mysql/296820>\
**Category:** programming\
**Created:** [September 21, 2009, 1:43pm UTC](https://forum.kirupa.com/t/how-can-i-retrieve-a-record-in-mysql/296820 "2009-09-21T13:43:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fries4me](https://avatars.discourse-cdn.com/v4/letter/f/ba9def/32.png) [@fries4me](https://forum.kirupa.com/u/fries4me)\
**Post date:** [September 21, 2009, 1:43pm UTC](https://forum.kirupa.com/t/how-can-i-retrieve-a-record-in-mysql/296820/1 "2009-09-21T13:43:35Z")

</div>

hello everyone! I have a problem with my login code… I have here a code that deals with an empty result set in mysql… I have already dealt with that problem. However, I got into another problem which is the retrieval of a record if the result set is not empty… I am hoping for your reply… thanks!

```
if($row=mysql_num_rows($result)==0){
    echo "EMPTY";
}
else{
while($row=mysql_fetch_assoc($result)){
    $userID=$row['id_num'];
    $userName=$row['name'];
    $userPass=$row['password'];
    echo "&lt;form action='index.php' method='POST'&gt;";
    echo "&lt;input type='hidden' name='userID' value='$userID'&gt;";
    echo "&lt;input type='hidden' name='userName' value='$userName'&gt;";
    echo "&lt;input type='hidden' name='userPass' value='$userPass'&gt;";
    echo "&lt;/form&gt;";
}

```

$userID=isset($\_POST[‘userID’]) ? $\_POST[‘userID’] :"";  
$userPass=isset($\_POST[‘userPass’]) ? $\_POST[‘userPass’] :"";  
$userName=isset($\_POST[‘userName’]) ? $\_POST[‘userName’] :"";

echo “JUST CHECKING—\<br\>input: $id\<br\>$pass2\<br\>Table:$userID\<br\>$userPass\<br\>—\<br\>”;

```
    if($userID==""&&$userPass){
    echo "&lt;br&gt;No Entry";
    }
    if($pass2!=$userPass){//password field is empty or mismatch
    echo "Passwords do not match";
    }
    if($id!=$userID){
    echo "&lt;br&gt;ID numbers do not match";
    }
    else{
    echo "Welcome $userName";
    }

```

}
