Jump to content

Function appears in the wrong place


gos1

Recommended Posts

hi. I need some help on including a function.
[code]
function echo_rooms_button(){
        $get_room_types_qr = "SELECT * FROM rooms";
        $get_room_types = mysql_query($get_room_types_qr);
            for($i =0 ; $i < mysql_num_rows($get_room_types); $i++) {
                    $type = mysql_result($get_room_types,$i,"type");
                    $fee = mysql_result($get_room_types,$i,"fee");
                    print '<label>'.$type.'->'.
                    $fee.'

                    <input name="rooms" type="radio" value="'.$type.'" />
                    </label><br>
                    ';

                    }
}
[/code]
here is the function I like to include but when I echo a text and this function the output of the function appears always on top. ex:
[code]
echo "a text here".echo_rooms_button();
[/code]
I got first the echo_rooms_button()'s output and then the a text here. But when I try this with time() function I got firstly the text and then the time() functions output. Can anyone help me what is wrong with my function ??
Link to comment
Share on other sites

[code]function echo_rooms_button(){
$get_room_types_qr = "SELECT * FROM rooms";
$get_room_types = mysql_query($get_room_types_qr);
for($i =0 ; $i < mysql_num_rows($get_room_types); $i++){
  $type = mysql_result($get_room_types,$i,"type");
  $fee = mysql_result($get_room_types,$i,"fee");
  $retun .= '<label>'.$type.'->'.$fee.'<input name="rooms" type="radio" value="'.$type.'" /></label><br>';
}
return $return;
}[/code]
Link to comment
Share on other sites

I used that function exactly and returned no result. Nothing echoed.
I am using this function in a variablle like
[code]
$comment = '<br><tr><td>'.echo_rooms_button().'</td></tr>';
echo $comment;
[/code]
but the function did not echoed anything in the file.
Link to comment
Share on other sites

sorry... typo
[code]function echo_rooms_button(){
$get_room_types_qr = "SELECT * FROM rooms";
$get_room_types = mysql_query($get_room_types_qr);
for($i =0 ; $i < mysql_num_rows($get_room_types); $i++){
  $type = mysql_result($get_room_types,$i,"type");
  $fee = mysql_result($get_room_types,$i,"fee");
  $return .= '<label>'.$type.'->'.$fee.'<input name="rooms" type="radio" value="'.$type.'" /></label><br>';
}
return $return;
}[/code]
Link to comment
Share on other sites

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.