Using a selection from a drop down menu

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • emnawroc
    New Member
    • Mar 2013
    • 2

    Using a selection from a drop down menu

    I am creating a RSS feed display. I need to be able to select a number from a drop down box and use it to display that number of feeds.
    I guess i am unsure of where to put the requested tag.


    Code:
    <?php
    $site_err = NULL;
    $my_num = 25; //sets num to 25 by default
    $num = NULL;
    ?>
    
    <form method="post" action="feed_rss.php">
        <label for="site">URL:</label>
        <input type="text" name="site" id="site" />
        <?php
        if($site_err != NULL){
            echo "<span class = \"error\">$site_err</span>";
        }
        ?>
        <br />
    
    
        <label for='num'>Num of Feeds:</label>
        <select name='num'>
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
            <option value="6">6</option>
            <option value="7">7</option>
            <option value="8">8</option>
            <option value="9">9</option>
            <option value="10">10</option>
            <option value="11">11</option>
            <option value="12">12</option>
            <option value="13">13</option>
            <option value="14">14</option>
            <option value="15">15</option>
            <option value="16">16</option>
            <option value="17">17</option>
            <option value="18">18</option>
            <option value="19">19</option>
            <option value="20">20</option>
            <option value="21">21</option>
            <option value="22">22</option>
            <option value="23">23</option>
            <option value="24">24</option>
            <option value="25">25</option>
        </select>
        <br />
    
        <label for="sort">Sort:</label>
        <select name="sort">
            <option value="Ascending">Ascending</option>
            <option value="Descending">Descending</option>
            <option value="Random">Random</option>
    
        </select>
        <br />
    
        <input type="submit" name="submit" value="Submit" class="submit-button" />
    </form>
    
    <!--Logic    -->
    
    
    <!--http://www.engadget.com/rss.xml-->
    <?php
    $rss = simplexml_load_file($_POST['site']);
    ?>
    
    <h1><?php echo $rss->channel->title; ?></h1>
    <ul>
    
    <?php
        $variable=$_REQUEST['num'];
        for ($x = 0; $x < $variable; $x++)
            foreach($rss->channel->item as $chan) {
                echo "<li><a href=\"".$chan->link."\">";
                echo $chan->title;
                echo "</a></li>\n";
                }
    
    ?>
    Last edited by Rabbit; Mar 5 '13, 07:43 PM. Reason: Added code tags.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    I don't know what you mean when you say "where to put the requested tag". Define tag. What tag are you talking about? What line of code are you referencing?

    Comment

    • emnawroc
      New Member
      • Mar 2013
      • 2

      #3
      I switched it up a bit to use an input box instead of a drop down. But i need to print the number of rss feeds from an inserted url based on the number they enter into the text box if that makes sense. I think I was more or less talking about line 72, but after doing a little more editing, i'm not sure that is what i needed to use. I have ended up using $_POST and I think i have figured it out myself. but thanks for the reply

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Please post your solution so that if someone else has the same problem, they can benefit from your solution.

        Comment

        Working...