0

Ok, so this is cool. On my site, I learned how to create a simplified "wall" like facebook has... sort of. It's great for me to have done that because I am self taught with all of this. There is a problem, however. My <option> is not displaying the names correctly. It should display each name listed in the database separately, instead it is showing displaying them as a runon sentence. I don't understand why the <br> command isn't working. Here is the php:

<?php
$query=mysqli_query($rcon,"SELECT userid FROM registration");
while ($row=mysqli_fetch_array($query)){
echo $row['userid'] . '<br>';}
?>

and here is the other code

<?php

include('php/wall.php');

?>
<form name="response" action="messages/enterblog.php" method="POST">
To:<select name="respondto">
<option name="to"><?php require('connect/registerdb.php'); include('messages/list.php');?></option>
</select>
Message:<input type="text" name="respond">
<input type="submit">
</form>
</div>

Here is what is displayed.
rountest

as opposed to
roun
test

2
Contributors
3
Replies
23
Views
3 Years
Discussion Span
Last Post by david.roun.7
1

You could try something like this.. something pretty easy without function and no object..

$option_block = ''; //this actually prevent the error just in case it is zero results.

$query=mysqli_query($rcon,"SELECT userid FROM registration");
    while ($row=mysqli_fetch_array($query)){

    $option_block .= '<option name="to">'.$row['userid'].'</option>';
}

then on your page witht he form, you can do like this.. I am guessing on the file structure here, because I don't where the actual query result is coming from.

require_once('connect/registerdb.php');
require_once('messages/list.php');

To:<select name="respondto">
        <?php echo $option_block;?>
</select>

that's pretty much it...good luck to you.

0

Got it. Here is the final php code. I needed to open and close the <option> tags in the loop. Thanks for the idea, as you can see I incorporated most of what you did in the final code.

<?php require('connect/registerdb.php');

echo '<select name="respondto">';

$query=mysqli_query($rcon,"SELECT userid FROM registration");
while ($row=mysqli_fetch_array($query)){

echo '<option name="to">' . $row['userid'] . '</option>';}
echo '</select>';
?>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.