View Single Post
  #20 (permalink)  
Old 12-01-09, 03:19 PM
alane alane is offline
Newbie Coder
 
Join Date: Jul 2005
Posts: 71
Thanks: 6
Thanked 0 Times in 0 Posts
Sorry for delay replying but I wanted to use weekent to try out REGEXP suggestion but couldn't get it to work.

Do I just have to replace my original code
PHP Code:

$query "SELECT 

    model, 
    brand, 
    gc_number, 
    dir, 
    manuals_pdffiles.id, 
    pdf_file, 
    category, 
    pdf_info, 
    DATE_FORMAT(date_available, '%d %b %y') AS Fdate, 
    safety, 
    asbestos,
    class 
FROM 
    manuals_models 
LEFT JOIN 
    manuals_pdffiles ON manual_id = manuals_pdffiles.id 
LEFT JOIN 
    manuals_brands ON brand_id = manuals_brands.id 
WHERE 
    (model like '%
$entry%') AND class = 1 
ORDER BY 
    brand, model "

with this or do I have to change anything else?
PHP Code:

$sRegExp preg_replace('/\W/''[[:punct:][:print:]]*'$entry);

$query "SELECT
    model,
    brand,
    gc_number,
    dir,
    manuals_pdffiles.id,
    pdf_file,
    category,
    pdf_info,
    DATE_FORMAT(date_available, '%d %b %y') AS Fdate,
    safety,
    asbestos,
    class
FROM
    manuals_models
LEFT JOIN
    manuals_pdffiles ON manual_id = manuals_pdffiles.id
LEFT JOIN
    manuals_brands ON brand_id = manuals_brands.id
WHERE
    model REGEXP '
$sRegExp' AND class = 1
ORDER BY
    brand, model "

The nested REPLACE version seems to work ok.

Thanks for your help and suggestions.
Reply With Quote