//$searchtext="" ;
echo("

$searchtext") ;
IF (isset($searchjoke)):
$searchtext="" ;
// BEGIN Enter Search Data
?>

METHOD=GET>
Please enter Search Text:

// LINE 13
$searchtext=rtrim($searchtext);
echo("

$searchtext") ;
ELSE:
// BEGIN Connect to the database server
$dbcnx = @mysql_connect("localhost", "ddm993c", "winscale1");
if (!$dbcnx) {
echo( "

Unable to connect to the " .
"database server at this time.

" );
exit();
}
// Select the jokes database
if (! @mysql_select_db("ddm993c_jokes") ) {
echo( "

Unable to locate the joke " .
"database at this time.

" );
exit();
}
// END Connect to the database server
// LINE 31
// BEGIN RETRIEVE AND DISPLAY JOKES
// works - 'SELECT * FROM `Jokes` ORDER BY `ID` ASC LIMIT 0, 30 ';
// works - "SELECT * FROM Jokes"
echo("

Here are all the jokes " .
"in The database:

");
// Request the ID and text of all the jokes
if( $searchtext=="") :
echo("

searchtext is:" . $searchtext) ;
$result = mysql_query('SELECT * FROM `Jokes` ORDER BY `ID` DESC LIMIT 0, 30 ');
echo("

$result

");
else:
echo("

searchtext is:" . $searchtext) ;
$result = mysql_query('SELECT * FROM `Jokes` WHERE `JokeText` LIKE CONVERT(_utf8 \'%$searchtext%\' USING latin1) COLLATE latin1_general_ci');
// $result = mysql_query('SELECT * FROM `Jokes` WHERE `JokeText` LIKE CONVERT(_utf8 \'%Joke Number 6%\' USING latin1) COLLATE latin1_general_ci');
// $result = mysql_query('SELECT * FROM `Jokes` WHERE `JokeText` LIKE "Joke Number 6" ');
// $result = mysql_query('SELECT * FROM `Jokes` WHERE `JokeText` LIKE \'%$searchtext%\' ');
$searchtext="";
echo("$result");
ENDIF;
// $result = mysql_query('SELECT * FROM `Jokes` WHERE 'JokeText' LIKE \'Joke Number Three\' ');
if (!$result) {
echo("

Error performing query: " .
mysql_error() . "

");
exit();
}
// DISPLAY the text of each joke in a paragraph
// with a "Delete this Joke" link next to each.
// if records present
//if (mysql_num_rows($result) > 0):
for($i=0; $i {
$row = mysql_fetch_array($result);
$jokeid = $row["ID"];
$joketext = $row["JokeText"];
echo("

$i . $jokeid . $joketext ");
}

// while ( $row = mysql_fetch_array($result) ) {
// $jokeid = $row["ID"];
// $joketext = $row["JokeText"];
// echo("

$jokeid . $joketext ");
// }
//ELSE:
// echo("

No Result");
//ENDIF;
// END RETRIEVE AND DISPLAY ALL JOKES


// BEGIN Search Link
// When clicked, this link will load this page
// with the joke sEARCH form displayed.
echo("

" . "Search Jokes

");

// END Search Link
ENDIF;
?>