Jump to content

How To Assign A Value To A Select Box Selection Jquerymobile


PeekAtU

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

Archived

This topic is now archived and is closed to further replies.

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