473,795 Members | 2,967 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

similar_text, mysql prob

Hi,

I was wondering if anyone here had a decent solution to this mysql/php
problem.

I have a mysql database with a list of groups (group_id, group_name,
group_location, group_time, group_day). group_name must be unique for
each group_location - so there is only ever one particular group name
per group location.

I want to let users join a group or add a new group as they please. The
user is provided with a form to fill out group_name, group_location,
group_time, group_day and they post the form to a php page that checks
what groups are in a particular location.

I want to provide to the user information in this order:
1.)exact group_name match if there is one (showing the details of the group)
2.)the group information they provided in the posted form if there are
no exact matches
3.)close group_name matches if there are some (showing the details of
the group)

This is an intuitively ordered list and makes it all the more user friendly.

So after the user posts the form page to the checking page, I have a
query that selects the group_id of the group_name they selected:

$query_group = "SELECT group_name FROM groups WHERE group_id =
'".$_POST['group_id']."'";

Then I do a while loop with $row = mysql_fetch_arr ay($query_group ) and
have an if then else for various options:

$row['group_name'] = $_POST['group_name']
$row['group_name'] = $_POST['group_name']

and for similar text:
similar_text(st rtoupper($group _name), strtoupper($row['group_name']),
$similarity_pst );

Where I show similar matching group_names if
(number_format( $similarity_pst , 0) > 90){

Of course this is all out of order if the first row is similar matching
then it shows the similar match before a later exact match in the mysql
table.

How do I get a well-ordered output as indicated above? I don't want a
lot of nested queries to achieve it (one query for exact, one query for
LIKE and no match). Is there an elegant solution? Maybe dump out all
groups for the specified group_location and push the matching score onto
the array and sort?? Or maybe a temp table - no idea, never used that in
mysql.

I would also like to use the better string comparison power of
similar_text or even levenshtein in php.

Help much appreciated.

Cheers

Rene
Jul 17 '05 #1
0 2090

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2763
by: george | last post by:
(driving me nuts) Hi there. I wonder if anyone can help? I'm including a page from Google in search.php, passing some parameters. So far so good. Then I'm asking to look through that Google page for a text match, and return true or false. eregi returns false whatever the case, similar_text returns true whatever the case. Can someone sort me out - oops, HELP me out ?
0
2641
by: Pieter Van Waeyenberge | last post by:
Hello i have most recent php & mysql versions running on a linuxmachine i want to use LOAD DATA LOCAL INFILE and pass it from php to mysql. - the file i load is given with full path and the directory is readble - On MySQL local-infile = ON - From PHP i connect using client flag (128) to allow passing a file over that connection: mysq_connect( $host, $usr, $pwd, false, 128)
1
2125
by: Stephan Heckmueller | last post by:
Hallo, in der Dokumentation von o.g. Funktion wird eine Arbeit von Oliver aus dem Jahre 93 erwaehnt; kann mir jemand den genauen Titel mitteilen? In welcher Datei des PHP-Quellcodes ist die obige Funktion implementiert? danke. PS: Anworten bitte auch via eMail.
175
11517
by: Sai Hertz And Control Systems | last post by:
Dear all, Their was a huge rore about MySQL recently for something in java functions now theirs one more http://www.mysql.com/doc/en/News-5.0.x.html Does this concern anyone. What I think is PostgreSQL would have less USP's (Uniqe Selling Points
2
1439
by: trihanhcie | last post by:
Hi, Well the following query is not the one i will use but it's the same prob : SELECT sum(country_id ) , count( country_id ) FROM Tbl_Country, Tbl_config WHERE country_id =1 Well ...the result should be sum(country_id )= 1 et count( country_id
15
6724
by: l3vi | last post by:
I have a new system Im building that stores entries of what people are searching for on my sites. I want to be able to keep records of how many times a keyword was searched for daily, and from that I can calculate weekly and monthly. At this point I have one entry per search phrase with the number of hits the search phrase has gotten, and the last time it was updated. As I start to take the program out of testing and move in more...
1
2098
omerbutt
by: omerbutt | last post by:
hi there i am new to php ,have been working in asp classic and access but now have switched to php and mysql,and for the practice sake i started to convert my asp and access based projects into php and mysql, i have a inventory system in which i have a stock entry Portion which has aloots of fields concerning to the codeno,partno, auto , product,quantity, size, height and lots of other fields too but our main concern is with these two "CODENO...
7
1894
omerbutt
by: omerbutt | last post by:
hi there i am having a prob with the date format i have an inventory application in which i have to make a SALES BILL ENTRY FORM i ma using php & mysql for storing the fields and for the back-end programming i am using the following code for the date with the format "month-date-year" <? $date=date("m-j-Y"); ?> <tr>
0
904
by: jahskee | last post by:
I have a prob maybe some of you guys already experienced this. I want to integrate the Mysql server to be displayed in the ide under the datasource Window of the VC#2005 Express Edition.
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10436
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10163
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10000
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7538
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3722
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.