I have a array from the database which contains links, some values are normal as "index.php" but others look like "browse.php|search.php|calendar.php|tags.php?tags_mode=profile|search.php?show=match", but I only want to use the first path "browse.php" only and trash everything starting from the first "|" inclusively.. how can I do that?
This is the code I have:
$sql = "SELECT * FROM $tablename WHERE `Parent` = '0' AND Type LIKE 'top' ORDER BY `Order` ASC";
$result = mysql_query($sql) or die ("Error: Query Failed! " .mysql_error());
$output = "<ul>";
while ($rs = mysql_fetch_array($result)) {
$output .= "<li class='menu_top' id='".$rs['ID']."'><a href='".$rs['Link']."'>".$rs['Name']."</a></li>";
$sql2 = "SELECT * FROM $tablename WHERE `Parent` = '".$rs['ID']."' ORDER BY `Order` ASC";
$result2 = mysql_query($sql2) or die ("Error: Query Failed! " .mysql_error());
if (mysql_num_rows($result2) != 0) {
$output .= "<ul class='menu_sub' id='".$rs['ID']."'>";
while ($rs2 = mysql_fetch_array($result2)){
$output .= "<li><a href='".$rs2['Link']."'>".$rs2['Name']."</a></li>";
}
$output .= "</ul>";
}
}
$output .="</ul>";
echo $output;
$rs['Link']
is the one I want to be cut like that..
I tried to subtract but I can't really say I can manage it as I am too new to php.. Thank you for any advice..