Have an account? Sign in
Login  Register  Facebook
Help with php queries
1) My first query is how can i get the values from an array to be passed into a mysql query for the following part.

I have a dropdown select box with to options that have values assigned to them code below:

<tr>
    <th>
        <label for="user_level">
         User Level: *  <?php echo isset($valid_user_level) ? $valid_user_level : NULL; ?>
        </label>
    </th>
</tr>
<td>
    <select name="user_level" id="user_level" class="sel">
        <option value="">Select one…</option>
        <option value="1">User</option>
        <option value="5">Admin</option>
    </select>
</td>
I want to create an array that will pass the options and insert the value of 1 or 5 into the database.
$sel = array();

How can i pass the data to the array that will pass the value of the field seleceted i.e if admin was selected value passed into the database would be 5.

I need the dropdown box to show the user the names such as user or admin etc.

2) What code is required for me to show the last time a user logged into their account, for example if i logg in on 01/01/2011 at 10.30 and again at the cuurent date and time but i want the user to be able to see the last time they logged in.

3) What query is required to show the current users online are, example i have 5 users currently online and i want to display the current users online what php code is required for this?

Thank you

Wishing you a happy new year.
Started: September 22, 2011 Latest Activity: September 22, 2011 php mysql phpmysql

Too many questions at once, and all three are not really answerable without knowing your database structure and how your login system works.
September 22, 2011

1 Answer
1) My first query is how can i get the values from an array to be passed into a mysql query for the following part.
$sel = $_REQUEST["user_level"];
2) What code is required for me to show the last time a user logged into their account,
print db("SELECT logintime FROM user WHER name=?", $username)->logintime;
3) What query is required to show the current users online are,
print db("SELECT count(session_id) ....");
Though that very much depends on your database structure and implementation. Hence this faux answer.

Posted: MacOS
In: September 22, 2011

Your Answer

xDo you want to answer this question? Please login or create an account to post your answer