I know I am pretty close with this, as I have recieved some help on this topic earlier, but when it cam to making the same code work for another part of the site it seems I cannot get it working again.
What I am doing is trying to get the first part of a string (which is broken by a -
delimiter in the database) so the db entry slug
would be foo-bar-rules
, I need to grab foo
from that string where slug
is not equal to foo-bar-rules
but equal to phoo-bar-rules
or feuw-bar-rules
. Am sorry if my explanation was'nt very helpful, I had trouble explaning it to myself :D.
Thank you in advance anyone that can help me out here..
<?php define ('PAGEPARENT', 'foo');
define ('PAGECHILD', 'bar');
define ('PAGEGRANDCHILD', 'rules');
switch (PAGEGRANDCHILD) {
case PAGEGRANDCHILD:
$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."-') + 1) = '$pageGrandChild'
AND grandchild = 1
AND slug != '".PAGEPARENT."-".PAGECHILD."-".PAGEGRANDCHILD."';
");
while ($rangeRelationRow = mysql_fetch_object($rangeRelationResult)) { ?>
<a href="?page=<?php echo $rangeRelationRow->result."-".PAGECHILD."-".PAGEGRANDCHILD; ?>&pageLevel=<?php echo $_GET['pageLevel']; ?>" title="<?php echo PAGEGRANDCHILD." for ".$rangeRelationRow->result; ?>"><div id="<?php echo $rangeRelationRow->result; ?>Channel"><?php echo "» ".ucwords(PAGECHILD)." for ".$rangeRelationRow->result; ?></div></a> <?php
}
break;
} ?>