these are my codes for list file the code is [php]<?php
$hostname = “localhost”; // usually is localhost, but if not sure, check with your hosting company, if you are with webune leave as localhost
$db_user = “root”; // change to your database password
$db_password = “pakkiz”; // change to your database password
$database = “search”; // provide your database name
$db_table = “searchengine”; // leave this as is
STOP HERE
####################################################################
THIS CODE IS USED TO CONNECT TO THE MYSQL DATABASE
$db = mysql_connect($hostname, $db_user, $db_password);
mysql_select_db($database,$db);
?>
Add your url to out database
<?php
if (isset($_REQUEST['Submit'])) {
# THIS CODE TELL MYSQL TO INSERT THE DATA FROM THE FORM INTO YOUR MYSQL TABLE
$sql = "INSERT INTO $db_table(title,description,url,keywords) values ('".mysql_real_escape_string(stripslashes($_REQUEST['title']))."','".mysql_real_escape_string(stripslashes($_REQUEST['description']))."','".mysql_real_escape_string(stripslashes($_REQUEST['url']))."','".mysql_real_escape_string(stripslashes($_REQUEST['keywords']))."')";
if($result = mysql_query($sql ,$db)) {
echo '
Thank you
Your information has been entered into our database
';
} else {
echo "ERROR: ".mysql_error();
}
} else {
?>
Add url
          Title:
         
          Description:
         
          Url:
http://
          Keywords:
         
         
<?php
}
?>
[/php]
for search code is [php]<?php
//get data
$button = $_GET[‘submit’];
$search = $_GET[‘search’];
$s = $_GET[‘s’];
if (!$s)
$s = 0;
$e = 10; // Just change to how many results you want per page
$next = $s + $e;
$prev = $s - $e;
if (strlen($search) < 1) {
echo “You must enter a search query.”;
}
else
{
echo "
";
//connect to database
mysql_connect(“localhost:3063”,“u635743540_root”,“Safi123”);
mysql_select_db(“u635743540_search”);
//explode out search term
$search_exploded = explode(" ",$search);
foreach($search_exploded as $search_each)
{
//construct query
$x++;
if ($x==1)
$construct .= "keywords LIKE '%$search_each%'";
else
$construct .= " OR keywords LIKE '%$search_each%'";
}
//echo outconstruct
$constructx = “SELECT * FROM searchengine WHERE $construct”;
$construct = “SELECT * FROM searchengine WHERE $construct LIMIT $s,$e”;
$run = mysql_query($constructx);
$foundnum = mysql_num_rows($run);
$run_two = mysql_query("$construct");
if ($foundnum==0)
echo “No results found for $search”;
else
{
echo “
Showing 1-10 of $foundnum results found for $search.
|
”;
while ($runrows = mysql_fetch_assoc($run_two))
{
//get data
$title = $runrows[‘title’];
$desc = $runrows[‘description’];
$url = $runrows[‘url’];
echo "
";
}
?>
<?php
if (!$s<=0)
echo " Prev";
$i =1;
for ($x=0;$x<$foundnum;$x=$x+$e)
{
echo " $i ";
$i++;
}
if ($s<$foundnum-$e)
echo " Next";
}
}
?>
|
[/php]
is this code right or wrong i have use this