Hi, I have setup a basic database, where you submit a persons information. - You input there name, address, telephone, age, religion etc…
The problem I am getting is when you search an age, for example ‘17’ it would also bring up results with people who have ‘17’ within their telephone number (07567651761).
Each bit of data is input to a MySQL table cell. - Here is the code I am using at the moment for the search string to pick out the data from a cell.
<?php function get_num_posts() {
$search_string = isset($_POST['search_string']) ? check_input($_POST['search_string']) : '';
$result = $GLOBALS['db']->query("SELECT COUNT(p.post_id) FROM " . $GLOBALS['config']['db']['prefix'] . "database_posts p LEFT OUTER JOIN " . $GLOBALS['config']['db']['prefix'] . "categories c ON p.category_id = c.category_id
WHERE p.title LIKE '%$search_string%' OR p.age
LIKE '%$search_string%' OR p.agegroup
LIKE '%$search_string%' OR p.gender
LIKE '%$search_string%' OR p.ethnic_id
LIKE '%$search_string%' OR p.religion
LIKE '%$search_string%' OR p.lifestage
LIKE '%$search_string%' OR p.address_line1
LIKE '%$search_string%' OR p.address_line2
LIKE '%$search_string%' OR p.city
LIKE '%$search_string%' OR p.county
LIKE '%$search_string%' OR p.postcode
LIKE '%$search_string%' OR p.occupation
LIKE '%$search_string%' OR p.ocother
LIKE '%$search_string%' OR p.jobtitle
LIKE '%$search_string%' OR p.hoccupation
LIKE '%$search_string%' OR p.hjobtitle
LIKE '%$search_string%' OR p.hseg
LIKE '%$search_string%' OR p.email
LIKE '%$search_string%' OR p.phone
LIKE '%$search_string%' OR p.mobile
LIKE '%$search_string%' OR p.cage
LIKE '%$search_string%' OR p.cage2
LIKE '%$search_string%' OR p.cage3
LIKE '%$search_string%' OR p.cage4
LIKE '%$search_string%' OR p.cage5
LIKE '%$search_string%' OR p.clifestage
LIKE '%$search_string%' OR p.clifeother
LIKE '%$search_string%' OR p.pets
LIKE '%$search_string%' OR p.pets2
LIKE '%$search_string%' OR p.pets3
LIKE '%$search_string%' OR p.pets4
LIKE '%$search_string%' OR p.cmake
LIKE '%$search_string%' OR p.cmake2
LIKE '%$search_string%' OR p.cmodel
LIKE '%$search_string%' OR p.regyear
LIKE '%$search_string%' OR p.ctype
LIKE '%$search_string%' OR p.ctype2
LIKE '%$search_string%' OR p.mobprov
LIKE '%$search_string%' OR p.mobprov2
LIKE '%$search_string%' OR p.internet
LIKE '%$search_string%' OR p.internet2
LIKE '%$search_string%' OR p.gas
LIKE '%$search_string%' OR p.gas2
LIKE '%$search_string%' OR p.electric
LIKE '%$search_string%' OR p.electric2
LIKE '%$search_string%' OR p.landline
LIKE '%$search_string%' OR p.landline2
LIKE '%$search_string%' OR p.tvprov
LIKE '%$search_string%' OR p.tvprov2
LIKE '%$search_string%' OR p.pastres
LIKE '%$search_string%' OR p.socialgrad
LIKE '%$search_string%' OR p.reshistory
LIKE '%$search_string%' OR p.reshistory2
LIKE '%$search_string%' OR p.findme
LIKE '%$search_string%' OR p.findme2
LIKE '%$search_string%' OR p.content
LIKE '%$search_string%' OR c.category_name
LIKE '%$search_string%'");
return $GLOBALS['db']->result($result, 0);
} ?>
If anyone has any tips on how each search phrase can be searched exact, rather than picking up on other words or numbers within a database that would be great.
Ok, where I am at is that when you search, search results are to specific. If for example you search EDF, you would hope that all results would return with people using EDF Energy. - Instead it also shows people from bEDFordshire because it has the letters EDF in it.
Is there a way so that it will only pick up the single letters EDF rather than the letters within a word?
The quotes that you are using for the HTML attributes should be double quotes instead.
Single quotes for PHP strings, double quotes for HTML attributes.
With regards to the if statement you wrote to show links only if a post is made… how can you input some PHP code rather than a link? Here is what I tried but it didn’t work, it just shows the line of PHP code as text…
I have also tried it with “” rather than ‘’ and returned this error…
Parse error: syntax error, unexpected ‘]’, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\inetpub\wwwroot\admin\ emplates\database\posts\index.tpl.php on line 25
Line 25 is …
Parse error: syntax error, unexpected ‘]’, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\inetpub\wwwroot\admin\ emplates\database\posts\index.tpl.php on line 25
No I only want the ‘$emails = $post[“email”]; $emails = implode(“;”,array_unique($emails))’ line to work if there are posts (results). If there are no posts made then I don’t want the code to work.
This line ‘$emails = $post[“email”]; $emails = implode(“;”,array_unique($emails))’ currently just reads as text when there are posts, when really I want the code to actually work.
Now my next problem (sorry, it’s just one after another ) - now that the code works fine the email link which is supposed to pick up from the line of code in the if statement doesn’t load.