Dear All,

I am very happy to be here. I have got alots help from this forum.
I don't know how to show my search result on the same page.

My Code
index.php

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script language="javascript" type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script language="javascript" type="text/javascript" src="jquery.jSuggest.1.0.js"></script>

<title>Simple English Online Dictionary</title>
<script type="text/javascript">

$(function($){

	$("#searchterm").jSuggest({
		minchar: 3,
 		zindex: 20000,
 		delay: 2500,
 		loadingImg: 'ajax-loader_green1.gif',
 		loadingText: 'Searching...',
 		autoChange: true,
		url: "suggestion.php?",
		type: "GET",
		data: "searchterm",

	});
})(jQuery);

</script>
</head>
<body>

<center>
	<p>You can search the meaning of word.</p>

	<div id="stylized">
		<form action="search.php" method="GET">
		<b>English Word :</b> 
		<input name="searchterm" type="text" id ="searchterm" />
		<input type=submit value="search">
		</form>
	</div>
</body>
</html>

Search.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
<title>Simple Online Dictionary</title>
<script type="text/javascript" src="jquery-1.2.6.min.js"></script>
<script type="text/javascript" src="jquery.dbPopWin-1.0.0.js"></script>
</head>
<body>
 <script type="text/javascript">
	$(document).ready(function()
		{
			$('a[rel="dbPopWin"]').click(
				function()
				{
					return $.dbPopWin( $(this).attr('href'), { dbPopWinWidth: 800, dbPopWinHeight: 600 } );
				}
			);
		}
	);
</script>

<?

$db_name="mydic";

trim($searchterm);

if (!$HTTP_GET_VARS["searchterm"])
{
echo "You haven't entered any word to search.Please, go back and entered it.";
exit;
}
$searchterm = addslashes($searchterm);
require("dict.php");
if (!$db)
{
echo "Error. Can't connect to database.Please try later";
}

mysql_select_db($db_name);
$query = "select * from words where engword like '".$HTTP_GET_VARS["searchterm"]."%' order by engword";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);


echo "<ul>";

for ($i=0; $i <$num_results; $i++)
while($data = mysql_fetch_array($result))

{     

echo "<li>{$data['engword']}</li>";
echo "<a href=\"http://localhost/dict/audio_en/{$data['engword']}.mp3\" title=\"open the audio file for the word {$data['engword']} \"rel='dbPopWin'><img src='audio.gif' alt = open the audio file for the word {$data['engword']} ></a>";

echo "  ";
echo (stripslashes($data["mword"])). "</li>";
echo " </br>";
echo " </br>";

}
echo "</ul>";

mysql_close($db);

echo "<br><br><a href='index.php'>search another word</a>";

?>

</body>
</html>

Could you give me please a tip on it.

Many thank in advance.

regards,
saya

Would this be a solution?

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script language="javascript" type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script language="javascript" type="text/javascript" src="jquery.jSuggest.1.0.js"></script>

<title>Simple English Online Dictionary</title>
<script type="text/javascript">

$(function($){

	$("#searchterm").jSuggest({
		minchar: 3,
 		zindex: 20000,
 		delay: 2500,
 		loadingImg: 'ajax-loader_green1.gif',
 		loadingText: 'Searching...',
 		autoChange: true,
		url: "suggestion.php?",
		type: "GET",
		data: "searchterm",

	});
})(jQuery);

</script>
</head>
<body>

<center>
	<p>You can search the meaning of word.</p>

	<div id="stylized">
		<form action="search.php" method="GET">
		<b>English Word :</b> 
		<input name="searchterm" type="text" id ="searchterm" />
		<input type=submit value="search">
		</form>
	</div>
<hr>
 <script type="text/javascript">
	$(document).ready(function()
		{
			$('a[rel="dbPopWin"]').click(
				function()
				{
					return $.dbPopWin( $(this).attr('href'), { dbPopWinWidth: 800, dbPopWinHeight: 600 } );
				}
			);
		}
	);
</script>

<?

$db_name="mydic";

trim($searchterm);

if (!$HTTP_GET_VARS["searchterm"])
{
echo "You haven't entered any word to search.Please, go back and entered it.";
exit;
}
$searchterm = addslashes($searchterm);
require("dict.php");
if (!$db)
{
echo "Error. Can't connect to database.Please try later";
}

mysql_select_db($db_name);
$query = "select * from words where engword like '".$HTTP_GET_VARS["searchterm"]."%' order by engword";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);


echo "<ul>";

for ($i=0; $i <$num_results; $i++)
while($data = mysql_fetch_array($result))

{     

echo "<li>{$data['engword']}</li>";
echo "<a href=\"http://localhost/dict/audio_en/{$data['engword']}.mp3\" title=\"open the audio file for the word {$data['engword']} \"rel='dbPopWin'><img src='audio.gif' alt = open the audio file for the word {$data['engword']} ></a>";

echo "  ";
echo (stripslashes($data["mword"])). "</li>";
echo " </br>";
echo " </br>";

}
echo "</ul>";

mysql_close($db);

echo "<br><br><a href='index.php'>search another word</a>";

?>
</body>
</html>

$HTTP_GET_VARS is not available till php5 or higher!
Use $_GET superglobal instead!

Dear All,

Thankyou very much all.

I added <form action="<?php echo $_SERVER; ?>" method="_GET" name="search">

and work fine very well.

regards,
saya

Could you help me on my search result formatting? Currently very bad. I could not solve the problem.
I want to make a better/clean result page and all the english word must be left align in the table.

here is the screenshot from the result.
http://screencast.com/t/OIHBshH1Mp

for ($i=0; $i <$num_results; $i++)
while($data = mysql_fetch_array($result))

{     
echo "<br />";
echo"<table border='1'>";

		echo "<tr>";
		echo "<td align='left'>";
		echo "{$data['engword']}";
		echo "</td>";
		echo "<td  align='left'>";
		echo "<a href=\"http://localhost/dict/audio_en/{$data['engword']}.mp3\" target='new' class='popup-link' title=\"open the audio file for the word {$data['engword']} \" >
		<img src='audio.gif' alt = open the audio file for the word {$data['engword']} ></a>";
		echo "</td>";
		echo "<td  align='left'>";
		echo (stripslashes($data["mword"]));
		echo"<td>";
		
echo"</tr>";

echo "</table>";
}

mysql_close($db);

?>
</body>
</html>

many thanks in advance,

saya.

while you're printing the results via while cycle,
you should place the table start and </table> closing tag out of thr while cycle.

if you determine a table, let set a default width. like:
<table width="434" border="1">

And you code is not valid, images and their ALT tag should placed between bouble qoutes (").

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.