Take the 2-minute tour ×

Anyone able to have at look at this? still un-resolved and am desperate to get this working, I am confident I know how the code is working, it is just a problem with the WHERE clause.

I need it so that the var $pageGrandChild matches the last part of a string in the database i.e. foo-bar-rules. Any ideas?

$pageGrandChild = PAGEGRANDCHILD;
$rangeRelationResult = mysql_query("SELECT DISTINCT SUBSTRING(slug, 1, INSTR(slug, '-') - 1) result
                                    FROM web_navbar_links
                                    WHERE SUBSTRING(slug FROM INSTR(slug, '".PAGECHILD."') + 2) = '$pageGrandChild'
                                    AND grandchild = 1
                                    AND slug != '".PAGEPARENT."-".PAGECHILD."-".PAGEGRANDCHILD."'

Thank you for reading and sorry I have posted this twice.

share|improve this question
Please don't post duplicates, they are very much frowned upon around here. I'll post a comment in the other question –  Pekka 웃 Oct 25 '10 at 10:01
possible duplicate of Slight problem getting mySQL SUBSTRING to work.. –  Pekka 웃 Oct 25 '10 at 10:01
add comment

1 Answer

up vote 1 down vote accepted
<?php mysql_query('...WHERE foo-bar-rules LIKE "%'.$pageGrandChild.'"...'); ?>


share|improve this answer
add comment

Your Answer


