reddavis999 Posted May 16, 2007 Share Posted May 16, 2007 Hi, ive created a simple search engine for a college project ive been working on. Heres the code... <?php session_start(); if ($_SESSION['logged'] != true) { header('location: register.php'); exit(); } ?> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>jobs</title> <meta name="generator" content="TextMate http://macromates.com/"> <meta name="author" content="Red Davis"> <!-- Date: 2007-05-08 --> <link rel="stylesheet" media="screen" type="text/css" href="style.css"/> </head> <body> <div id="header"> <div id="header1"> </div> <div id="header2"> </div> <div id="logo"> </div> <div id="header3"> </div> <div id="tabs"> </div> </div> <div id="leftbar"> </div> <div id="links1" <div id="home"><a href="index_logged_in.php">Home</a></div> <div id="investor"><a href="investor.htm">Investor</a></div> <div id="jobs"><a href="jobs.php">Jobs</a></div> <div id="register"><a href="register.php">Register</a></div> </div> <div id="welcome"> <?php echo "Welcome, ".$_SESSION['username'] ; ?> </div> <div id="logout"> <a href="logout.php">Logout</a> </div> <?php include ("name.inc"); mysql_connect ("$host","$username","$password") or die ("couldnt connect"); mysql_select_db ("$database") or die ("cannot select database"); //set variables $request = $_GET['dropdown']; $search = mysql_query("SELECT * FROM $table2 WHERE jobtype='$request'") or die (mysql_error()); while ($row = mysql_fetch_array($search)) { echo $row['jobtitle']."<br>"; } ?> <div id="rightbar"> </div> </body> </html> The search works fine but i want it to return links. So that if the user searched programmer jobs, the search would return the job title and a link to the full article (which would contain jobdescription). A bit like the youtube search. Thanks for your help, Red Quote Link to comment https://forums.phpfreaks.com/topic/51647-solved-simple-search-engine-and-links/ Share on other sites More sharing options...
heckenschutze Posted May 16, 2007 Share Posted May 16, 2007 Are the URLs in the SQL table? Also consider creating a seperate file that connects to your DB and selects it... Quote Link to comment https://forums.phpfreaks.com/topic/51647-solved-simple-search-engine-and-links/#findComment-254419 Share on other sites More sharing options...
reddavis999 Posted May 16, 2007 Author Share Posted May 16, 2007 no there not. Would i have to create a script to create a new html file everytime some uploads a job? then put the link to that file into the database? thats for the advice. Quote Link to comment https://forums.phpfreaks.com/topic/51647-solved-simple-search-engine-and-links/#findComment-254474 Share on other sites More sharing options...
MadTechie Posted May 16, 2007 Share Posted May 16, 2007 Have a php page thats fetch's the data from a database and builds the page ie page.php?id=1 select * from tabel where ID = $_GET['ID']; etc if you need more detail i can post it. Quote Link to comment https://forums.phpfreaks.com/topic/51647-solved-simple-search-engine-and-links/#findComment-254477 Share on other sites More sharing options...
reddavis999 Posted May 16, 2007 Author Share Posted May 16, 2007 thanks please correct me if im wrong... When a user submits a job, it goes to a script that creates a new page. This page is then stored in a table along with the job name, description etc.? Then when a user seaches 'programmer' jobs it will display links for the jobs, so when the user clicks on them it goes the page that was created earlier? What is this type of thing called, when it has .php?id=1 ? becuase i would like to look for some tutorials on it to learn more. thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/51647-solved-simple-search-engine-and-links/#findComment-254500 Share on other sites More sharing options...
The Little Guy Posted May 16, 2007 Share Posted May 16, 2007 My site has something like this: http://snippets.tzfiles.com Each snippet has its own ID number, and when a user clicks on a link, the all use the same file (snippet.php) but each has its own unique values in the URL ?id=3 or ?id=34 etc. and like said above the page layout stays the same, only the content is generated from a data source such as a database. Quote Link to comment https://forums.phpfreaks.com/topic/51647-solved-simple-search-engine-and-links/#findComment-254514 Share on other sites More sharing options...
reddavis999 Posted May 16, 2007 Author Share Posted May 16, 2007 ok ok. I think its starting to click. Do you know of any tutorials, because im still a bit confused about how these ids are stored. ??? I probably need a little rest thanks Quote Link to comment https://forums.phpfreaks.com/topic/51647-solved-simple-search-engine-and-links/#findComment-254521 Share on other sites More sharing options...
The Little Guy Posted May 16, 2007 Share Posted May 16, 2007 There should be a column in your database that is set to auto_increment (this must be a primary key, and an int of some sort such as bigint), and then you just search the database for that id. Quote Link to comment https://forums.phpfreaks.com/topic/51647-solved-simple-search-engine-and-links/#findComment-254546 Share on other sites More sharing options...
reddavis999 Posted May 16, 2007 Author Share Posted May 16, 2007 ahhh ok. i get you. thanks for all you help. Red Quote Link to comment https://forums.phpfreaks.com/topic/51647-solved-simple-search-engine-and-links/#findComment-254552 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.