[insert_php]
ob_start();

function doHighlight ($strNeedle, $strHaystack, $inLink){

//this fixes bug if first char is a <
if(strpos($strHaystack,”<")==0) {$strHaystack = " " . $strHaystack;} $strHaystack = str_replace("\"","'",$strHaystack); $newString = ""; $i = 0; //only do it if we have a tag $findtag = strpos($strHaystack,"<"); if ($findtag > 0){
//count how many tags we have
$strCount = substr_count( $strHaystack,”<"); //and loop that many times while($i < $strCount){ $i++; //find opening tag $pos = strpos( $strHaystack,"<"); //get text to left of opening tag $Stringstart = substr($strHaystack , 0, $pos); //highlight that text $pattern = $strNeedle; $su_replacement = '‘.$strNeedle.’‘;
$highlightedString = preg_replace(“/” . $pattern .”/”, $su_replacement , $Stringstart);
//build the new string
$newString = $newString . $highlightedString;

//find closing tag and concatenate it to new string without highlighting
$strRemainder = substr($strHaystack, $pos);
$pos = strpos( $strRemainder,”>”);
$Stringstart = substr($strRemainder , 0, $pos);
$newString = $newString . $Stringstart;

//make the rest of the String the new string and loop
$strHaystack = substr($strRemainder, $pos);
}
}
//if no tag, return the highlighted String
else{
$pattern = $strNeedle;
$su_replacement = ‘‘.ucwords($strNeedle).’‘;

if($inLink==1){
$su_replacement = ‘‘. ucwords($strNeedle).’‘;
}
$newString = str_ireplace( $pattern , $su_replacement , $strHaystack);

//echo “\n” . ‘ ns = ‘ . $pattern. “/”. $su_replacement .’/’. $strHaystack . ‘/’ . $newString .”\n”;
}

echo(trim($newString) . ” “);
}

$host=”localhost”;
$dbname=”richardg_wp”;
$user=”richardg_mysql”;
$pass=”sc0rpex”;
try {

# MySQL with PDO_MYSQL
$dbh = new PDO(“mysql:host=$host;dbname=$dbname”, $user, $pass);

}
catch(PDOException $e) {
echo $e->getMessage();
}
$theorder = “”;

if(isset($_COOKIE[‘songorder’]) && $_COOKIE[‘songorder’] != “”){
$theorder=$_COOKIE[‘songorder’];
}
if(isset($_GET[“order”]) && $_GET[“order”] != “”){
$theorder=$_GET[“order”];
}

switch ($theorder){

case “t”: // title
$strSQL = “SELECT * FROM su_songs ORDER by songTitle ASC”;
$cookievalue=”t”;
break;

case “a”: // artist
$strSQL = “SELECT * FROM su_songs ORDER by songArtist ASC”;
$cookievalue=”a”;
break;

case “n”:
$strSQL = “SELECT * FROM su_songs ORDER by songID DESC”;
$cookievalue=”n”;
break;

case “k”: // key
$strSQL = “SELECT * FROM su_songs ORDER by songKey ASC, songTitle ASC”;
$cookievalue=”k”;
break;

case “c”: //chords
$strSQL = “SELECT * FROM su_songs WHERE songChordCount > 0 ORDER by songChordCount DESC, songTitle ASC”;
$cookievalue=”c”;
break;

default:
$cookievalue=”t”;
$strSQL = “SELECT * FROM su_songs ORDER by songTitle ASC”;
break;

}

//set a cookie so reloads in same order as last time
setcookie(“songorder”, $cookievalue, time() + 31536000);
ob_flush();

$strSearch=””;
// our search SQL
if(isset($_REQUEST[“searchstring”]) && $_REQUEST[“searchstring”] > “”){
$strSearch = $_REQUEST[“searchstring”];

//clear our order
if(isset($_GET[“order”])) {$_GET[“order”]=””;}

$strSQL = “SELECT * FROM su_songs WHERE `songTitle` LIKE ‘%”. str_replace(“‘”, “‘” ,$_REQUEST[“searchstring”]) . “%’ OR `songArtist` LIKE ‘%”. str_replace(“‘”, “‘” ,$_REQUEST[“searchstring”]) . “%’ ORDER BY songTitle”;
}
//echo $strSQL;
$sth = $dbh->prepare($strSQL);
$sth->execute();
$total = $sth->rowCount();

[/insert_php]



Appreciate Richard’s work making these [insert_php]echo $total;[/insert_php] free ukulele songs for you? 
?

 

Legend: Song title   Key/Chord count   –   Artist

[insert_php]
while($row = $sth->fetch()){

echo “

“;
if ($strSearch) {
doHighlight($strSearch, trim(stripslashes($row[“songTitle”])),1);
}
else{
echo trim(stripslashes($row[“songTitle”])) . “
“;
}
echo ” ” . $row[‘songKey’] . “/” . $row[‘songChordCount’] . ” – “;
if ($strSearch) {
doHighlight($strSearch, trim(stripslashes($row[“songArtist”])),1);
}
else{
echo trim(stripslashes($row[“songArtist”])) . ” “;
}
echo ”

“;
};
[/insert_php]

1300+ ukulele songs and tabs