Jump to content

Adding items through PHP into HTML Combobox


noobstar

Recommended Posts

Well this has to be the stupidest thing i've seen, ive done this so many times before yet this stupid thing alludes me i can't seem to see the problem with it.

 

What i have here is a simple messaging service that displays all messages sent to the particular user. I've got 3 sample messages in there for testing now next to each of the messages it should have a combo box that will display options of Folders they created to move the messages to that area.

Now, the problem lies on the combo box it does it perfectly on the first message but when it creates the other 2 combo boxes (for the other 2 sample messages) they come out blank, which doesn't make any sense to me what so ever :(.

 

Have a look at the Code below and you might be able to figure it out cause i've been pondering for over 2 days now:

 

PM.PHP

<table border="0" width="650">
            	<tr>
                	<td class="SideNote" align="center">Folders</td> 
                	<td class="SideNote" align="center">Delete</td>
                    <td class="SideNote" align="center">From</td>
                    <td class="SideNote" align="center">Subject</td>
                    <td class="SideNote" align="center"></td>
                </tr>
            	<?php
			echo "<tr>";
			$RowspanFolders = $MessageResult['MessageCount'] + 1;
			echo "<td class='MessageBorder' style='padding-left:15px;text-align:left' width='150' rowspan='".$RowspanFolders."'>";
				while($PM_Folders_Links = mysql_fetch_assoc($PM_Folders_Query)) {
					echo "<img src='images/foldericon.png' />";
					echo "<a href='pm.php?folder=".$PM_Folders_Links['folders_Name']."'>".$PM_Folders_Links['folders_Name']."</a><br/>";
				}
			echo "<br/><a href='pm.php?newfolder=true'>New Folder</a></td></tr>";
			while($InboxResult = mysql_fetch_assoc($InboxQuery)) {
            	echo "<tr>";
                echo "<td class='MessageBorder'><input type='checkbox' name='chkDelete' class='SideNote' /></td>";
			echo "<td class='MessageBorder' width='80'><span class='SideNote'>".$InboxResult['pmbox_From']."</span></td>";
                echo "<td class='MessageBorder' width='450'><a href='pm.php?checkmsg=true&pmbox_ID=".$InboxResult['pmbox_ID']."'>".$InboxResult['pmbox_Subject']."</a></td>";
                echo "<td class='MessageBorder'><select name='cboMoveOpt' class='textbox_button'>";
                                        //This is the bit that fails for some odd reason
				while($PM_Folders_ComboB_R = mysql_fetch_assoc($PM_Folders_ComboB_Q)) {
					echo "<option value='".$PM_Folders_ComboB_R['folders_Name']."'>".$PM_Folders_ComboB_R['folders_Name']."</option>";
				}
			echo "</select></td>";
			}
			echo "</tr>";
			?>
</table>

 

QUERIES.PHP

<?php

$SitemapQuery = mysql_query("SELECT * FROM rstar_links") or die('Sitemap query did not work!');

$MessageQuery = mysql_query("SELECT count(pmbox_ID) as MessageCount FROM rstar_pmbox WHERE pmbox_To = '".$_SESSION['username']."'") or die('Message query failed');
$MessageResult = mysql_fetch_assoc($MessageQuery) or die('Message result did not get query');
$InboxQuery = mysql_query("SELECT * FROM rstar_pmbox WHERE pmbox_To = '".$_SESSION['username']."'") or die('Inbox query failed');

$NewsfeedQuery = mysql_query("SELECT * FROM rstar_newsfeed") or die('Newsfeed query failed');
$NewsfeedResult = mysql_fetch_assoc($NewsfeedQuery);

$PMDisplay = mysql_query("SELECT * FROM rstar_pmbox WHERE pmbox_ID = '".$_REQUEST['pmbox_ID']."'") or die('PMDisplay query failed');
$PMDisplayResult = mysql_fetch_assoc($PMDisplay);

$PM_Folders_ComboB_Q = mysql_query("SELECT * FROM rstar_pmbox_folders WHERE folders_Username = '".$_SESSION['username']."'") or die('PM_Folders_ComboB_Q failed!');
$PM_Folders_Query = mysql_query("SELECT * FROM rstar_pmbox_folders WHERE folders_Username = '".$_SESSION['username']."'") or die('PM_Folders_Query failed!');
$PM_Folders_Count = mysql_query("SELECT count(folders_ID) as FolderCount FROM rstar_pmbox_folders WHERE folders_Username = '".$_SESSION['username']."'") or die('PM_Folders_Count query failed!');
$PM_Folders_Count_R = mysql_fetch_assoc($PM_Folders_Count);

?>

 

 

Thank you for any help what so ever!

 

Link to comment
Share on other sites

The output code is above in the PM.php script file, if that's what you mean.

 

Just to show you what happens here is a screenshot:

picture1qy1.png

As you can see it does it without problems on the first combo box but the other 2 remain empty ...

 

Very very odd

 

 

EDIT:

I just wanted to further test it so i wrapped the While loop inside a For loop so it basically duplicates the output 4 times, code is shown below:

 

for($i=0;$i<=3;$i++) {
    echo "<select name='cboMoveOpt' class='textbox_button'>";
        while($PM_Folders_ComboB_R = mysql_fetch_assoc($PM_Folders_ComboB_Q)) {
    echo "<option value='".$PM_Folders_ComboB_R['folders_Name']."'>".$PM_Folders_ComboB_R['folders_Name']."</option>";
}
    echo "</select>";
}

 

The output is exactly the same as the other code it does it perfectly for the first time and then its blank for the other 3 combo boxes

Link to comment
Share on other sites

Sorry for a double post but just to add onto it

 

I chucked in a second while statement (the one that displays links to the folders) inside the for loop along with the Combobox while loop and as the combobox while loop it only displays the links to the folders ones and that's it.

 

From what i gather its ...

A) You can't display the stuff from the database more then ones (which i think is rubbish cause i'm sure i've done it before)

B) There is something wrong with 'MAMP' >.>

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.