Advanced Search

Results 1 to 3 of 3

Thread: PHP Search script help

  1. #1
    Join Date
    May 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default PHP Search script help

    Code:
    <html>
     <head>
      <title>PHP Test</title>
     </head>
     <body>
    <?php
    // specify url of xml file
    $url = "http://xmlfeed.laterooms.com/index.aspx?aid=11657&rtype=4&kword=london";
    // get xml file contents
    $xml = simplexml_load_file($url);
    
    // loop begins
    foreach($xml->hotel as $hotel)
    {
    // begin new paragraph
    echo "<p>";
    echo "<img src=".$hotel->images." height=100 width=100><br/>";
    echo "<strong>Hotel Name:</strong> ".$hotel->hotel_name."<br/>";
    echo "<strong>Hotel City:</strong> ".$hotel->hotel_city."<br/>";
    echo "<strong>Prices From:</strong> &pound;".$hotel->prices_from."<br/>";
    echo "<strong>Hotel Link:</strong><a href=".$hotel->hotel_link.">click here</a><br/>";
    echo "</p>";
    // end paragraph
    }
    // loop ends
    
    ?>
     </body>
    </html>
    Hi there, I am trying to create a textbox and button for the user to change the key word on the following line

    Code:
    $url = "http://xmlfeed.laterooms.com/index.aspx?aid=11657&rtype=4&kword=london";
    Thankyou for your help in advance

  2. #2
    Join Date
    May 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Sorry... the textbox and button should control kword=london and change the word london to whatever the user types in the textbox

    Thankyou

  3. #3
    Join Date
    Mar 2011
    Location
    N 11 19' 0.0012 E 142 15' 0
    Posts
    1,508
    Thanks
    41
    Thanked 89 Times in 88 Posts
    Blog Entries
    3

    Default

    Code:
    <html>
     <head>
      <title>PHP Test</title>
     </head>
     <body>
    <?php
    if(isset($_POST['urlInput'])) {
    $urlGet = mysql_real_escape_string($_POST['urlInput']);
    $url = "http://xmlfeed.laterooms.com/index.aspx?aid=11657&rtype=4&kword=" . $urlGet;
    // specify url of xml file
    // get xml file contents
    $xml = simplexml_load_file($url);
    
    // loop begins
    foreach($xml->hotel as $hotel)
    {
    // begin new paragraph
    echo "<p>";
    echo "<img src=".$hotel->images." height=100 width=100><br/>";
    echo "<strong>Hotel Name:</strong> ".$hotel->hotel_name."<br/>";
    echo "<strong>Hotel City:</strong> ".$hotel->hotel_city."<br/>";
    echo "<strong>Prices From:</strong> &pound;".$hotel->prices_from."<br/>";
    echo "<strong>Hotel Link:</strong><a href=".$hotel->hotel_link.">click here</a><br/>";
    echo "</p>";
    // end paragraph
    }
    // loop ends
    } else {
    echo '<form aciton="" method="post">';
    echo "Url:";
    echo '<input type="text" name="urlInput">';
    echo '<input type="submit" value="submit">';
    echo '</form>';
    }
    ?>
     </body>
    </html>

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •