Hi, I am a complete newbie to PHP & mysql.
I have created a database for my website...i want to be able to search the database for a keyword eg "hairdresser" and for it to return all the entries which include this keyword. I don't want people to see a search box or anything, i just want the results to be sitting there for them when they open that page.
I have learnt what i know so far (not much) from online tutorials, however i cant seem to find any information on how to display the data i have in my table in this manner.
If anyone could help me, provide me with some code or direct me to a online tutorial or something i would really appreciate it.
"search" database and display results on website
Moderator: General Moderators
Re: "search" database and display results on website
Well you need to pass a keyword to mysql to search for, so where do you plan on putting this in? Hardcoding it into each page (ie. bike.php would display all the bike info in the database, car.php would display all the car info in the database)?rlgriffo wrote:I don't want people to see a search box or anything, i just want the results to be sitting there for them when they open that page.
You could always do this with GET, ie.:
info.php?item=bike would display all the bike info on info.php
info.php?item=car would display all the car info on info.php
Sessions are an option. Just need more information on how you want this done.
Re: "search" database and display results on website
I think the way I would do this (if I'm understanding you correctly) is at the top of the page that I want to display hairdresser information I would do this:Then later on when I actually want to display the information, I would create a query
Code: Select all
<?php
$askingFor = "hairdresser";
?>Code: Select all
<?php
$sql = "SELECT $askingFor FROM mytable";
$result = mysql_query($sql) or die(mysql_error());
while($data = mysql_fetch_assoc($result))
doStuff($data['$askingFor']);
?>Re: "search" database and display results on website
So Sorry i didnt reply sooner after you spent your time replying....
My database is a database of businesses - hairdressers, bakeries, butchers, petshops all in together.
My database has several columns business_name, industry, address, phonenumber, email, suburb, information etc
I would like my website to have a home page --->businesses (they will choose a business category from a list of links eg hairdressers)----->a page showing a table of all of the hairdressers in the database showing their Name and Suburb one after the other. Basically the "Industry" and "Keywords" entered into the database will determine which category the hairdresser appears under.
Then I want people to be able to click on the hairdresser they want more info on and be taken to a screen with MORE of that particular hairdresser's details that I have entered in the database....eg name, address, phone number, email, information, images etc.
Is this possible?
Thank you
Sorry i didnt get back sooner.
My database is a database of businesses - hairdressers, bakeries, butchers, petshops all in together.
My database has several columns business_name, industry, address, phonenumber, email, suburb, information etc
I would like my website to have a home page --->businesses (they will choose a business category from a list of links eg hairdressers)----->a page showing a table of all of the hairdressers in the database showing their Name and Suburb one after the other. Basically the "Industry" and "Keywords" entered into the database will determine which category the hairdresser appears under.
Then I want people to be able to click on the hairdresser they want more info on and be taken to a screen with MORE of that particular hairdresser's details that I have entered in the database....eg name, address, phone number, email, information, images etc.
Is this possible?
Sorry i didnt get back sooner.