Fwd: change php variable depending on selection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---------- Forwarded message ----------
From: Nathan Nobbe <quickshiftin@xxxxxxxxx>
Date: Jan 21, 2008 10:43 AM
Subject: Re: [PHP] change php variable depending on selection
To: stp <stpra123@xxxxxxxxx>


On Jan 21, 2008 9:42 AM, stp <stpra123@xxxxxxxxx> wrote:

>  I'm sorry…..I've got the conversion of the actual feed itself already
> sorted out…… when I talk feed below, I am just referring to the *link*,
> i.e. for Yahoo Finance, the *link* would be
> http://finance.yahoo.com/rss/topstories. The only thing I am missing
> (besides half a brain to figure this out on my own) is the $rssFeeds
> variable and how to set that so that when the user selects "Yahoo Finance"
> from the drop down menu the $rssFeeds variable would be "
> http://finance.yahoo.com/rss/topstories";. I guess the variable would be
> something along the following:
>
> $rssFeeds=grab the "link" from my table associated with the "blogname" the
> user selects in the dropdown menu
>

please keep all responses to list topics on the list for the benefit of
others.

you need to build an array with the values from your database.  suppose, the
fields in your
database have column names feedName and feedUrl, then you will do something
like this
to build the array (assuming table name is RSS_FEEDS):

// connect to the database using mysql_connect()
if($resultSet = mysql_query('SELECT feedName, feedUrl FROM RSS_FEEDS')) {
    $rssFeeds = mysql_fetch_array($resultSet);
}

once youve done that, you can modify the code that builds the select box in
the example
i posted:
            <?php foreach($rssFeeds as  $curFeedName => $curFeedValue) { ?>
                <option value="<?=$curFeedName?>">
                    <?=$curFeedValue?>
                </option>
            <?php } ?>
will become
            <?php foreach($rssFeeds as  $curFeed) { ?>
                <option value=" <?=$curFeed['feedUrl']?>">
                    <?=$curFeed['feedName']?>
                </option>
             <?php } ?>
then, when the user makes a selection, the value of the $selectedValue
variable (from
the example script) will be the url of the feed they would like to see.

-nathan

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux