hi guys.. i need your help..
i want to display the user's login information.
like, storage location..but im not sure how to do it..
this is how i try to do it..

$tenantID = $_GET['tid'];

"
"
"

$query_recTenantuser = "SELECT * FROM md_storage WHERE tenantID='".$tenantID."'";   
$rs_recTenantuser = mysql_query($query_recTenantuser) or die ('Query failed: ' . mysql_error(). "<br />\n $query_recTenantuser");
$recTenantuser = mysql_num_rows($rs_recTenantuser);

"
"
"

<tr>
        <td class="labelcell"><strong>Storage Location</strong></td>
        <td> : </td>
        <td class="datacell">
            <select name="stID">
                <option value="">-Sila Pilih-</option>
                <?php
                    while ( ( $recTenantuser = mysql_fetch_array($rs_recTenantuser) ) != false ) {
                ?>
                    <option value="<?php echo $recTenantuser['stID']; ?>"><?php echo $recTenantuser['stLoc']; ?></option>
                <?php
                    } // close while
                ?>
            </select>
        </td>
    </tr>

if the user login, only the information about him/her will be shown.

Recommended Answers

All 5 Replies

Do something like this:-
once login is successful store userId in session

<?php
session_start();
$_SESSION['userId']=$_GET['tid'];
?>

And then to get user information use query:-

$query_recTenantuser = "SELECT * FROM md_storage WHERE tenantID='".$_SESSION['userId']."'";   
$rs_recTenantuser = mysql_query($query_recTenantuser) or die ('Query failed: ' . mysql_error(). "<br />\n $query_recTenantuser");
$recTenantuser = mysql_num_rows($rs_recTenantuser);

Rest of your code seems correct.Please explain what exactly you are looking for?

I would presume that the query:

$query_recTenantuser = "SELECT * FROM md_storage WHERE tenantID='".$tenantID."'"; 

will return just one row ($tenantID is probably unique), so in the select element (drop down) you will have only one option. That does not make senese. Correct me if I am wrong.

Whenever you want to keep track of a user's login, then u need to assign them a session. For instance In the login script, you will assign tenantId as a session, like so;

$_SESSION['tenantId']=$row['tid']; //Assuming $row holds the array values from the database.

Then in the page where you want to display user's details, you will add the session;

<?php
session_start();
$_SESSION['tenantId']=$tenantIdentifier; //Feches the session for the tenantId
?>

dear @IIM, @broj1, @webville312.

Thank you so much..it worked now.. i added

$_SESSION['tenantId']=$tenantIdentifier;

on the top of the page and edit the query just like what you taught me..
and it worked..Thanks again... :)

hi everyone, i've got quite similar with displaying user's information.
i've 2 form(K8 Form and K9 Form). To displaying user's information in K8 Form, i used the method with the way you guys taught me. and then after the user fill up the K8 Form, the K8 Form information will be displaying on K9 Form. and that is the problem.I used the same way to show the information but the information about K8 Form doesn't show up in the K9 Form. in K8 Form, the primary key is "k8goodsID".
here are the way i did :

$_SESSION['k8goodsID']=$tenantIdentifier;

"
"
"

$query_k8goodsin = "SELECT * FROM k8_goodsin WHERE k8goodsID='".$_SESSION['k8goodsID']."'"; 
$rs_k8goodsin = mysql_query($query_k8goodsin) or die ('Query failed:' . mysql_error() . "<br /><\n $query_k8goodsin");
$reck8goodsin = mysql_num_rows($rs_k8goodsin);

"
"
"

<table id="tblStore" width="491" border="1"  cellpadding="4px" cellspacing="0" bordercolor="#000000" >
<br />
<thead>  
    <th width="6%" class="labelcell">No</th>
    <th width="25%" class="labelcell">Goods</th>
    <th width="17%" class="labelcell">Quantity</th>
    <th width="18%" class="labelcell">Price per Unit</th>
    <th width="19%" class="labelcell">Total</th>
    <th width="13%" class="labelcell"></th>
</thead>
    <tr>
        <td class="labelcell"><?php echo $count; ?></td>
        <td><?php echo $reck8goodsin['goodsDesc']; ?></td>
       <td><?php echo $reck8goodsin['k8goodsQty']; ?></td>
       <td><?php echo $reck8goodsin['valuePerUnit']; ?></td>
       <td><?php echo $reck8goodsin['valueTotal']; ?></td>
       <td><input name="" type="checkbox" value="" /></td>
    </tr>
</table>

and for the checkbox, i want the user's can pick the goods and displaying the goods picked and submit it.
can someone help me..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.