Jump to content

How To Assign A Value To A Select Box Selection Jquerymobile


Recommended Posts

Hello I am having an issue assigning a variable to a select box selection so that i can feed the variable back into future queries. Please see code below:

  • <select name="room" id="msg-room">
  • <?php
  • $query = mysql_query("SELECT * FROM rooms ORDER BY ROOM asc");
  • while($data = mysql_fetch_assoc($query)) {
  • ?>
  • <option value="<?php echo $data["roomid"]; ?>"><?php echo $data["ROOM"]; ?></option>
  • <?php } ?>
  • </select>

The selection list loads and populates fine. I just need a way to assign $data["Room"] a variable so that I can insert it into the Heading of the page as well as back into a sql query that will return the number of users in a selected room.

  • <?php
  • $query = mysql_query('SELECT * from user where room = $data[room] and account_status=1')
  • or
  • die(mysql_error());
  • $num_rows = mysql_num_rows($query);
  • echo "$num_rows Users Online"

Please help. Thank you

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.