Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rating: Thread Rating: 16 votes, 4.00 average.
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-05-2008, 12:48 AM   PM User | #1
mia_tech
Regular Coder

 
Join Date: Jul 2007
Location: FL, USA
Posts: 153
Thanks: 13
Thanked 0 Times in 0 Posts
mia_tech can only hope to improve
php search box form...

I decided to do a search box following this php script http://php.about.com/od/phpwithmysql...p_search_3.htm which seems very simple, in my case I'm not using the options form only a simple search box, and the visitors will be searching for articles, but how should I go about input the article info on the table; I created a table called articles, with columns "name", "date", "description", "url"... my doubt is with the description column, should I enter the whole article in there, the first lines or a descriptive content about that specific article, it seemed to me that entering the whole content would take sometime, although there are tools to do bulk insert into mysql....I want that when users search they get back the title of the article with at least the first 2 or 3 lines, the date, and the url... yes, yes I know this can be done with google

any help appreciated

www.pctechtips.org

Last edited by mia_tech; 08-05-2008 at 12:55 AM..
mia_tech is offline   Reply With Quote
Old 08-05-2008, 03:27 AM   PM User | #2
masterofollies
Senior Coder

 
Join Date: May 2005
Posts: 2,137
Thanks: 96
Thanked 72 Times in 72 Posts
masterofollies can only hope to improve
I would hardcode the entire article in your script, it'd be too much on the database to pull out a whole page of text out.
masterofollies is offline   Reply With Quote
Old 08-05-2008, 04:56 AM   PM User | #3
mia_tech
Regular Coder

 
Join Date: Jul 2007
Location: FL, USA
Posts: 153
Thanks: 13
Thanked 0 Times in 0 Posts
mia_tech can only hope to improve
I'm just trying to get an idea how this is done..... how could I hard code the articles in the script... hint :0)


thanks

www.pctechtips.org
mia_tech is offline   Reply With Quote
Old 08-06-2008, 09:04 AM   PM User | #4
mia_tech
Regular Coder

 
Join Date: Jul 2007
Location: FL, USA
Posts: 153
Thanks: 13
Thanked 0 Times in 0 Posts
mia_tech can only hope to improve
I came up with my own search script the one found on the link above didn't quite worked for me, but still have a problem... and is that no matter what I search for I'm getting the whole content of the table back and the problem is on the sql string which I'm using
Code:
SELECT * FROM articles
and I realize that I should be using some sort of condition on my sql statement to match the user search, but I can put it into php terms if someone could give a hand....here the php code
PHP Code:
<?php
//open connection
$conn mysql_connect("localhost""root""password") or die(mysql_error());
//select database
mysql_select_db("test"$conn);
//the sql statement
$sql "SELECT * FROM articles";
//execute the statement
$data mysql_query($sql$conn) or die(mysql_error());
while (
$result mysql_fetch_array($data)) {
    
//giving names to the fields
    
$title $result['title'];
    
$date $result['date'];
    
$info $result['info'];
    
$url $result['url'];
    
//put the results on the screen
    
echo "<b>$title</b>";
    echo 
" ";
    echo 
"<b>$date</b><br>";
    echo 
"$info<br>";
    echo 
"$url<br>";
}
?>
and here is the search form
Code:
<h2>Search</h2>
<form name="search" method="post" action="search1.php">
Seach for: <input type="text" name="find" /> 
<input type="submit" name="search" value="Search" />
</form>
thanks

www.pctechtips.org
mia_tech is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:23 PM.


Advertisement
Log in to turn off these ads.