Jump to content

[SOLVED] question: can you have a drop down table holding values of a query?


runnerjp

Recommended Posts

ok im creating a pm system and its all working but i would like a user to be able to select from there friends list.... i was thinking about making a drop down table holding the query from there friends so all there friends will be within the query.... is this possible or is there a better option

ok i tried doing this (i think its the right path to go lol) but the table does not display anything lol

 

<?php
session_start();
require_once '../settings.php';
checkLogin ('1 2');
$username= get_username($_SESSION['user_id']);
$query = "SELECT * FROM `friends` WHERE `username`= '$username' ORDER BY username ASC;";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)){
$friends= $row['friendname'];}
$friends;
$lines = $friends;;
echo '<select class="inputedit" id="friends" name="friends">';
foreach($lines as $line) {
    echo '<option>'.$line.'</option>';
}
echo '</select>';?>

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.