473,406 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Getting spacific when searching?

Ajm113
161 100+
Ok, I am making a search engine in PHP and I want to know how I can have the user be able to select a box then enter in something like mark's. But since their can be anything like Mark's Script or Mark's Login page in php it can be hard to find what the user is looking for. So I made it so I can put the results in a category. Like software development in category 1 and webpage design in 2. So how can I have to so it will search the field titles and only pull up everything in catergory 1 or what ever?

Here is the script to pull up anything that is close to the title.

[PHP]$query = mysql_query("SELECT * FROM sites WHERE title LIKE '%$search%'", $dbh) or die( mysql_error() );
$resultnum = mysql_num_rows($query); // Just print $resultnum if you want to show how many results returned[/PHP]
Jun 7 '07 #1
7 1349
ak1dnar
1,584 Expert 1GB
Ok, I am making a search engine in PHP and I want to know how I can have the user be able to select a box then enter in something like mark's. But since their can be anything like Mark's Script or Mark's Login page in php it can be hard to find what the user is looking for. So I made it so I can put the results in a category. Like software development in category 1 and webpage design in 2. So how can I have to so it will search the field titles and only pull up everything in catergory 1 or what ever?

Here is the script to pull up anything that is close to the title.

[PHP]$query = mysql_query("SELECT * FROM sites WHERE title LIKE '%$search%'", $dbh) or die( mysql_error() );
$resultnum = mysql_num_rows($query); // Just print $resultnum if you want to show how many results returned[/PHP]
If you can provide more details, its highly appreciate.Please exaplin it further.
Jun 7 '07 #2
Ajm113
161 100+
Well I want the user to be able to select a catergory using a check box then enter in something like "PHP" in the text field then it will only bring up anything in the row "title" with the word "PHP" in that category of web design that the user selected on the checkbox. If thats a good way to explane it.

Thats how detailed I can go.
Jun 7 '07 #3
ak1dnar
1,584 Expert 1GB
Well I want the user to be able to select a category using a check box
well, that means your form contains with a text input box to enter a string and some check boxes to select the categories as you said.
Are you planing to let user to select multiple checkboxes?
For a example ;
Text Input : PHP
And he user might select web design category and again the web application category check boxes from the form.

How is your table structure goes ?
Jun 7 '07 #4
Ajm113
161 100+
Yes.

Well the catergorys will be called in numbers so it save some room. But isn't possible to add in multiable "LIKES" or mysql functions in one command?
Jun 7 '07 #5
ak1dnar
1,584 Expert 1GB
Yes.

Well the catergorys will be called in numbers so it save some room. But isn't possible to add in multiable "LIKES" or mysql functions in one command?
You can add multiple LIKES keyword to single MySQLqueryString.
If you can provide the table structures, form and the php script that yo made so far probably we can help you.
Jun 7 '07 #6
Ajm113
161 100+
Well you can look at the form's code here. Then you mite see what I am going for. Tables;

id -- views -- url -- title -- description -- type
int -- var(5) -- tinytext -- tinytext -- varchar(2)

I'm trying to speed this up becuase I am leaving today and I don't have alot of time befor I come back a while.
Jun 7 '07 #7
ak1dnar
1,584 Expert 1GB
There were lots of coding for this in this forum it self, even me also came across several times with this kind of situations.
Try this way big boy.

[HTML]<html>
<body bgcolor="E5E5E5">
<form action="search.php" method="POST">
<table class="main" align="center">
<tr>
<td align="center" bgcolor="#6666CC">
<input type="text" name="search" size="60">
<input type="submit" class="formbutton" value="Search">
</td></tr>
<tr><td align="center">
Software Programming <input type="checkbox" name="orgin1" value="1" />
Graphic Design <input type="checkbox" name="orgin2" value="2" />
Game Design (<i>Programming, Sound Design, Graphics</i>) <input type="checkbox" name="orgin3" value="3" />
Game Modding <input type="checkbox" name="orgin4" value="4" />
Web Design(<i>CSS, PHP, HTML</i>) <input type="checkbox" name="orgin5" value="5" />

</td></tr>
<tr><td align="center"><a href="tellme.php">Tell Us!</a></td></tr>
</table>
</form>
</body>
</html>[/HTML]

search.php

[PHP]<?php
$search_string= $_POST['search'];

$string = array();
$where = "";

for($i=1;$i<=5;$i++){
if (isset($_REQUEST['orgin'.$i.'']) AND !empty($_REQUEST['orgin'.$i.'']))
$string[] = " type = '".$_REQUEST['orgin'.$i.'']."' ";
}

if(!empty($string)){
$where = "WHERE title LIKE '%".$search_string."%' AND ".implode("OR", $string);
}
$sql="SELECT * FROM table_name $where GROUP BY col_id ORDER BY col_id asc";
echo $sql;
?>[/PHP]
Jun 8 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
15
by: middletree | last post by:
How do I request the actual page name that I'm on? This is going to go into an include file, and depending on which page I'm on, I'd like to do different things. I'm looking for "pagename.asp"
8
by: Hazz | last post by:
What is the triggering action that raises the event which causes my breakpoint to be reached, repeatedly, but does not allow my form to ever remain visible. I set a breakpoint on the line...
25
by: altemurbugra | last post by:
Hi is it possible to make search on for example on google without api with a list of words 1- there is word list 2- the script will take the words from the list by turn 3-it iwll make the search...
1
by: warheart | last post by:
hi im kinda new to programming i aint lazy to search and learn :D but i am getting despirate... ive been looking everywhere for a code to search a txt file and find a string, and then give...
1
by: darrel | last post by:
I've been struggling for some time now getting a RSS app to work. I'm creating RSS from existing XML files (transforming via XSLT). The problem is that the page, itself, is still being sent at...
10
by: jonathan184 | last post by:
Hi I tried getting this to work through dreamweaver but it did not. So i found a n example on the internet , i followed everything exactly the search script does not work. Could somebody help me...
2
by: rustyc | last post by:
Well, here's my first post in this forum (other than saying 'HI' over in the hi forum ;-) As I said over there: ... for a little side project at home, I'm writing a ham radio web site in...
6
by: bushwacker | last post by:
Hello all, I'm a chemical engineering student. our teacher has given us a project to do some calculations based on some equations. those equations include constants, which are to be read from a...
11
by: dougmeece | last post by:
OK so I have been able to fix all of my problems with much help from the experts...thank you experts. However, now something really weird is happening. As you know I have two forms (one...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.