Click here to Skip to main content
14,579,188 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hello everyone, I have such a small task to create a combo box in which to dynamically add addresses. it's not that hard I understand but as a beginner, I have no idea how to make this connection between form and PHP to present the feeds.

To obtain the DOM representation of the RSS document, I must first create the code by which to dynamically add the addresses from each link element of an item element to the combo box.

The for loop will go through the item elements, but the code for the dynamic filling of the select box will have to be done instead.

The articles should appear on the same page

Thank you in advance

What I have tried:

<form method="POST" action="" >
    <label for="Feed_element"> Posting a feed </label>
    <select id="combo" name="Make" onchange="document.getElementById('add_text').value=this.options[this.selectedIndex].text">
        <option value= "$url">Search for articles</option>
        <option value="">RSS-1</option>
        <option value="2">RSS-2</option>
        <option value="3">RSS-3</option>
    <input type="hidden" name="add_text" id="add_text" value="" />
    <input type="submit" name="search" value="Search" />


if (isset($_POST['search'])) {

    $makerValue = $_POST['Make']; // make value

    $maker = mysql_real_escape_string($_POST['add_text']); // get the selected text
    echo $maker;

$html = "";
// URL containing rss feed
$url = "";
$xml = simplexml_load_file($url);

for ($i = 0; $i < 1; $i++) {
    $title = $xml->channel->item[$i]->title;
    $link = $xml->channel->item[$i]->link;
    $description = $xml->channel->item[$i]->description;
    $pubDate = $xml->channel->item[$i]->pubDate;

    $html .= "<a href='$link'>$title</a>"; // Title of post
    $html .= "$description</br>"; // Description
    $html .= "<br />$pubDate<br /><br />"; // Date Published
echo "$html<br/>";

Updated 28-Jun-20 23:51pm
Richard MacCutchan 28-Jun-20 6:02am
What is the point of a for loop that only has a single iteration?
albatros 188 29-Jun-20 5:46am
for ($i =0; $i < 4; $i++) .... sorry

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

also, I'm not sure if I used this part of code in the right way.
<select id="combo" name="Make" onchange="document.getElementById('add_text').value=this.options[this.selectedIndex].text">

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100