Hi spaceshiptrooper
You have been very, very helpful and I appreciate it
Let me tell you what I dreamed up yesterday morning and have been trying to see if it can be done within my limits (with a lot of help…):
I want to search the database to see which hotel chains have hotels in specific cities.
I managed to create a database with 6 fields:Chain. Country. City. Top, Medium, Low
I also managed to connect to the database with a small script (not this one) and to upload a bunch of records to make sure things were working properly
Then, yesterday I looked for ways of placing a search box (or 2) in one of the pages and came up with this, which tells me that with some changes will be the way to go
http://pintotours.net/TEMP/TEST/search.html?q=andorra
Then, having convinced myself that that part is feasible, and realizing that the script we are talking about now, will start by validating the query in that box,I looked around to se how incredibly difficult it might turn out to be, and came to the conclusion that it easier than I thought.
This script that I found online serves only to tell me if the idea can be brought into practice with just this code altered to comply with my requirements:
If it can, then it will be time to put the final touches without forgetting, for instance, what i have been hearing for the past couple of days, in this and other threads, that “my” code is obsolete. But if it works tomorrow is good enough for me. When the time comes to publish, it will have been updated.
<!--
<input type="text" name="search" placeholder="Search...">
<input type= 'submit' name= 'btnsearch' value= 'search' id= 'btnsearch' onclick= 'this.form.action'/>
<input type = 'submit' name = 'download' value = 'save to excel'/>
-->
<?php
$user_name = "pintotou_****";
$password = "v*****";
$database = "pintotou_search";
$server = "localhost";
mysql_connect("localhost","pintotou_****","*****") or die ("could not connect");
mysql_select_db("pintotou_search") or die ("could not find db");
$output = '';
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
$searchq = $_POST['search'];
/*$searchq = preg_replace("#[^0-9a-z]#i","",$searchq);*/
$query = mysql_query("SELECT * FROM Chains WHERE Country LIKE '%$searchq%' OR City LIKE '%$searchq%'") or die ("could not search");
$count = mysql_num_rows($query);
if($count == FALSE)
{
$output = 'There was no search results!';
}
else
{
while($row = mysql_fetch_array($query)){
$id = $row['ID'];
$Chain = $row['Chain'];
$Country = $row['Country'];
$City = $row['City'];
$Top = $row['Top'];
$Medium = $row['Medium'];
$Low = $row['Low'];
$output .= 'ID : '.$ID.'<br>
Chain : '.$Chain.'<br>
Country : '.$Country.' <br>
City : '.$City.' <br>
Top : '.$Top.'<br>
Medium : '.$Medium.'<br>
Low : '.$Low.'<br>
-------------------------------------<br>';
}
}
print "$output";
}
?>
<?php
I’ve tested the script with echo statements and it connects to the server, but obviously it does not print “$output” because it does not know where to find the query.
That would be, I think, the first thing to do: connect the html in the page to the script.
Thank you again