Need help with scrollbox with dynamic php/mysql data

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
redtail
Forum Newbie
Posts: 4
Joined: Thu Feb 18, 2010 11:12 am

Need help with scrollbox with dynamic php/mysql data

Post by redtail »

I know this can be done, but I'm having problems finding an example of it.

Here's what I'm trying to do:

I've got php/mysql data coming in from a database into a css-scrollbox and want that
dynamic text (summary data) to be selectable. When selected, I want to display the detail field from
the record selected, into another display box area on the same screen. Sort of like a 'reader.'

Any examples?
Last edited by redtail on Thu Feb 18, 2010 6:22 pm, edited 1 time in total.
User avatar
manohoo
Forum Contributor
Posts: 201
Joined: Wed Dec 23, 2009 12:28 pm

Re: Need help with scrollbox with dynamic php/mysql data

Post by manohoo »

redtail, I will assume that array $array contains the values from the database.

Code: Select all

function selectOne($array=null) 
    {
        echo "<form action=\"\" method=\"post\">";
        echo "<SELECT name=anyName>"; 
        echo "<OPTION value=''>please choose one</OPTION>"; 
        foreach ($array as $key=>$value){
            echo "<OPTION value=$value>$value</OPTION>";
        }
        echo "</SELECT>";
        echo "<input name=\"sent\" type=\"hidden\" value=\"yes\">";
        echo "<input type=\"Submit\" value=\"Go!\">";
        echo "</form>";
 
      return null; 
    }
I didn't test the above, let me know if it doesn't work
redtail
Forum Newbie
Posts: 4
Joined: Thu Feb 18, 2010 11:12 am

Re: Need help with scrollbox with dynamic php/mysql data

Post by redtail »

manohoo wrote:redtail, I will assume that array $array contains the values from the database.

Code: Select all

function selectOne($array=null) 
    {
        echo "<form action=\"\" method=\"post\">";
        echo "<SELECT name=anyName>"; 
        echo "<OPTION value=''>please choose one</OPTION>"; 
        foreach ($array as $key=>$value){
            echo "<OPTION value=$value>$value</OPTION>";
        }
        echo "</SELECT>";
        echo "<input name=\"sent\" type=\"hidden\" value=\"yes\">";
        echo "<input type=\"Submit\" value=\"Go!\">";
        echo "</form>";
 
      return null; 
    }
I didn't test the above, let me know if it doesn't work
Hi Manohoo,

It looks like that will create a pull-down list. I don't think that's quite what I need. Here's a code
snippet of what I've got in a css-scrollbox, so far. I want to make these dynamic records selectable so that I can display the
corresponding large text field into another display box when one of these rows is selected.

for ($n=0; $n < $num_results_notes_all; $n++) {
if ($n%2) {
$backgrnd_color = 'row1';
} else {
$backgrnd_color = 'row2';
}
$row_notes_all = mysql_fetch_assoc($result_notes_all);
echo '<tr class=';
echo '"'.$backgrnd_color.'">';
echo '<td style="width: 218px; text-align: left;">';
echo htmlspecialchars(stripslashes($row_notes_all['description']));
echo '&nbsp';
echo '</td><td style="width: 90px; text-align: left;">';
echo htmlspecialchars(stripslashes($row_notes_all['note_date']));
echo '&nbsp&nbsp&nbsp';
echo '</td><td style="width: 88px; text-align: left;">';
echo htmlspecialchars(stripslashes($row_notes_all['note_time']));
echo '&nbsp&nbsp';
echo '</td></tr>';
}
Post Reply