Avatar billede crapmaster Nybegynder
19. maj 2005 - 22:08 Der er 4 kommentarer og
1 løsning

Hjælp til Søgning i php-fusion

Hej allesammen!

Jeg sider med denne dvdinfos ting ( En dvddatabase ) og er løbet lidt dø i en søning til den, Sagen er den at jeg ville bruge den søning som den er lavet som i koden nedeunder.

Det der skal søges efter i db er:

dvdinfos_name
dvdinfos_description
dvdinfos_nr


Er der ikke en der vil hjælpe mig med den, jeg er løbet helt kold.


Koden som det skal ind i:

<?
@require_once "fusion_config.php";
require_once "fusion_core.php";
require_once "subheader.php";
include FUSION_LANGUAGES.FUSION_LAN."search.php";
require_once "side_left.php";

opentable(LAN_400." ".$settings['sitename']);
if ($stype == "") $stype = "a";
echo "<form name='searchform' method='post' action='$PHP_SELF'>
<center>
".LAN_401." <input type='text' name='stext' value='".stripinput($stext)."' class='textbox' style='width:200px'>
<input type='submit' name='search' value='".LAN_400."' class='button'><br>
".LAN_402." <input type='radio' name='stype' value='n'".($stype == "n" ? " checked" : "")."> ".LAN_410."
<input type='radio' name='stype' value='a'".($stype == "a" ? " checked" : "")."> ".LAN_411."
<input type='radio' name='stype' value='fp'".($stype == "fp" ? " checked" : "")."> ".LAN_412."
<input type='radio' name='stype' value='foto'".($stype == "foto" ? " checked" : "")."> Fotoalbum

<input type='radio' name='stype' value='alt'".($stype == "alt" ? " checked" : "")."> Alt

</center>
</form>\n";
closetable();

if (isset($stext)) {
tablebreak();
if ($stext != "" && strlen($stext) >= 3) {

$query = stripinput($stext);
$query2 = htmlentities($query);

// søgning i nyheder __________________________________
// search in news:

if ($stype == "n" OR $stype == "alt") {
opentable('Søgeresultater i nyheder');
$sql = dbquery("SELECT * FROM ".$fusion_prefix."news WHERE news_subject LIKE '%".$query."%'
OR news_extended LIKE '%".$query."%'
OR news_news LIKE '%".$query."%'");
$rows = dbrows($sql);
if (!isset($rowstart)) $rowstart = 0;
if ($rows != 0) {
$sql = dbquery("SELECT * FROM ".$fusion_prefix."news WHERE news_subject LIKE '%".$query."%'
OR news_news LIKE '%".$query."%'
OR news_extended LIKE '%".$query."%'
ORDER BY news_datestamp DESC LIMIT $rowstart,10");
while ($data = dbarray($sql)) {
$numrows = dbcount("(news_id)", "news", "news_id>='".$data['news_id']."'");
if ($numrows > 10) {
$rstart = ceil($numrows / 10);
$rstart = "?rowstart=".(($rstart-1)*10);
} else {
$rstart = "";
}

// hvis $query er fundet i nyhedsteksten:
// if $query is found in news_news or news_extended:

if (eregi($query, $data['news_news']) OR eregi($query, $data['news_extended'])) {
echo "<img src='".FUSION_THEME."images/bullet.gif'> <a href='news.php".$rstart."#".$data['news_id']."'>".$data['news_subject']."</a><br>\n";
if (eregi($query, $data['news_news'])) {
echo parsesearch(stripslashes($data['news_news']),$query)."<br>\n";}
else {
echo parsesearch(stripslashes($data['news_extended']),$query)."<br>\n";}
echo "<span class='small2'>".LAN_420.LAN_424.LAN_422.showDate("longdate", $data['news_datestamp']).".</span><br><br>\n";
} else if (eregi($query, $data['news_extended'])) {
echo "<img src='".FUSION_THEME."images/bullet.gif'> <a href='news.php?readmore=".$data['news_id']."'>".$data['news_subject']."</a><br>\n";
echo parsesearch(stripslashes($data['news_extended']),$query)."<br>\n";
echo "<span class='small2'>".LAN_420.LAN_425.LAN_422.showDate("longdate", $data['news_datestamp']).".</span><br><br>\n";
}

// hvis query2 er fundet i nyhedens tekst:
// if $query2 is found in news_news or news_extended:

else if (eregi($query2, $data2['news_news']) OR eregi($query2, $data['news_extended'])) {
echo "<img src='".FUSION_THEME."images/bullet.gif'> <a href='news.php".$rstart."#".$data['news_id']."'>".$data['news_subject']."</a><br>\n";
if (eregi($query2, $data['news_news'])) {
echo parsesearch(stripslashes($data['news_news']),$query2)."<br>\n";}
else {
echo parsesearch(stripslashes($data['news_extended']),$query2)."<br>\n";}
echo "<span class='small2'>".LAN_420.LAN_424.LAN_422.showDate("longdate", $data['news_datestamp']).".</span><br><br>\n";
} else if (eregi($query2, $data['news_extended'])) {
echo "<img src='".FUSION_THEME."images/bullet.gif'> <a href='news.php?readmore=".$data['news_id']."'>".$data['news_subject']."</a><br>\n";
echo parsesearch(stripslashes($data['news_extended']),$query2)."<br>\n";
echo "<span class='small2'>".LAN_420.LAN_425.LAN_422.showDate("longdate", $data['news_datestamp']).".</span><br><br>\n";
}

// hvis $query el. $query2 er fundet i nyhedens overskrift:
// if $query or $query2 is found in news subject:

else if (eregi($query, $data['news_subject']) OR eregi($query2, $data['news_subject'])) {
if (eregi($query, $data['news_subject'])){
echo "<img src='".FUSION_THEME."images/bullet.gif'> <a href='news.php".$rstart."#".$data['news_id']."'>".parsesearch($data['news_subject'],$query)."</a><br>\n";}
else { echo "<img src='".FUSION_THEME."images/bullet.gif'> <a href='news.php".$rstart."#".$data['news_id']."'>".parsesearch($data['news_subject'],$query2)."</a><br>\n";}

echo trimlink(stripslashes($data['news_news']),100)."<br>\n";
echo "<span class='small2'>".LAN_420.LAN_423.LAN_422.showDate("longdate", $data['news_datestamp']).".</span><br><br>\n";
}

}
} else {
echo "<center><br>\n".LAN_440."<br><br>\n</center>\n";
}
closetable();
echo "<div align='center' style='margin-top:5px;'>\n".makePageNav($rowstart,10,$rows,3,"$PHP_SELF?stype=n&stext=$stext&")."\n</div>\n";

}


// søgning i artikler _________________________________
// Search in articles:

if ($stype == "a" OR $stype == "alt") {
opentable('Søgeresultater i artikler');
$sql = dbquery("SELECT * FROM ".$fusion_prefix."articles WHERE article_subject LIKE '%".$query."%' OR article_article LIKE '%".$query."%' OR article_article LIKE '%".$query2."%'" );
$rows = dbrows($sql);
if (!isset($rowstart)) $rowstart = 0;
if ($rows != 0) {
$sql = dbquery("SELECT * FROM ".$fusion_prefix."articles WHERE article_subject LIKE '%".$query."%' OR article_article LIKE '%".$query."%' OR article_article LIKE '%".$query2."%' ORDER BY article_datestamp DESC LIMIT $rowstart,10");
while ($data = dbarray($sql)) {

// hvis $query eller $query2 er fundet i artiklens tekst:
// if $query or $query2 is found in article text:

if (eregi($query, $data['article_article']) OR eregi($query2, $data['article_article'])) {
echo "<img src='".FUSION_THEME."images/bullet.gif'> <a href='readarticle.php?article_id=".$data['article_id']."'>".$data['article_subject']."</a><br>\n";
if (eregi($query, $data['article_article'])) {
echo parsesearch(stripslashes($data['article_article']),$query)."<br>\n"; }
else {
echo parsesearch(stripslashes($data['article_article']),$query2)."<br>\n"; }

echo "<img src='".FUSION_THEME."images/bullet.gif'> <span class='small2'>".LAN_420.LAN_427.LAN_422.showDate("longdate", $data['article_datestamp']).".</span><br><br>\n";
}


// hvis $query eller query2 er fundet i overskriften:
// if $query or $query2 is found in article subject:

else if (eregi($query, $data['article_subject']) OR eregi($query2, $data['article_subject'])) {
if (eregi($query, $data['article_subject'])) {
echo "<img src='".FUSION_THEME."images/bullet.gif'> <a href='readarticle.php?article_id=".$data['article_id']."'>".parsesearch($data['article_subject'],$query)."</a><br>\n";
}
else {
echo "<img src='".FUSION_THEME."images/bullet.gif'> <a href='readarticle.php?article_id=".$data['article_id']."'>".parsesearch($data['article_subject'],$query2)."</a><br>\n";
}
echo trimlink(stripslashes($data['article_article']),100)."<br>\n";
echo "<img src='".FUSION_THEME."images/bullet.gif'> <span class='small2'>".LAN_420.LAN_426.LAN_422.showDate("longdate", $data['article_datestamp']).".</span><br><br>\n";
}


}


} else {
echo "<center><br>\n".LAN_440."<br><br>\n</center>\n";
}
closetable();
echo "<div align='center' style='margin-top:5px;'>\n".makePageNav($rowstart,10,$rows,3,"$PHP_SELF?stype=a&stext=$stext&")."\n</div>\n";

}


// søgning i brugeroprettede artikler _____________________
// search in custom pages:

if ($stype == "a" OR $stype == "alt") {
opentable('Søgeresultater i brugeroprettede artikler');
$sql = dbquery("SELECT * FROM ".$fusion_prefix."custom_pages WHERE page_title LIKE '%".$query."%' OR page_content LIKE '%".$query."%' OR page_content LIKE '%".$query2."%'" );
$rows = dbrows($sql);
if (!isset($rowstart)) $rowstart = 0;
if ($rows != 0) {
$sql = dbquery("SELECT * FROM ".$fusion_prefix."custom_pages WHERE page_title LIKE '%".$query."%' OR page_content LIKE '%".$query."%' OR page_content LIKE '%".$query2."%'
LIMIT $rowstart,10");
while ($data = dbarray($sql)) {


// hvis $query eller $query2 er fundet i artiklens tekst:
// if $query or $query2 is found i article text:

if (eregi($query, $data['page_content']) OR eregi($query2, $data['page_content'])) {
echo "<img src='".FUSION_THEME."images/bullet.gif'> <a href='viewpage.php?page_id=".$data['page_id']."'>".$data['page_title']."</a><br>\n";

if (eregi($query, $data['page_content'])) {
echo parsesearch(stripslashes($data['page_content']),$query)."<br>\n";}
else {
echo parsesearch(stripslashes($data['page_content']),$query2)."<br>\n";}
echo "<img src='".FUSION_THEME."images/bullet.gif'> <span class='small2'>".LAN_420.LAN_427.".</span><br><br>\n";
}

// hvis $query eller $query2 er fundet i overskriften:
// if $query or $query2 is found i custom page title:

else if (eregi($query, $data['page_title']) OR eregi($query2, $data['page_title'])) {
echo "<img src='".FUSION_THEME."images/bullet.gif'> <a href='viewpage.php?page_id=".$data['page_id']."'>".parsesearch($data['page_title'],$query)."</a><br>\n";
echo trimlink(stripslashes($data['page_content']),100)."<br>\n";
echo "<img src='".FUSION_THEME."images/bullet.gif'> <span class='small2'>".LAN_420.LAN_426.".</span><br><br>\n";
}


}


} else {
echo "<center><br>\n".LAN_440."<br><br>\n</center>\n";
}
closetable();
echo "<div align='center' style='margin-top:5px;'>\n".makePageNav($rowstart,10,$rows,3,"$PHP_SELF?stype=a&stext=$stext&")."\n</div>\n";

}



// søgning i fotoalbums _____________________
// Search in photo albums

if ($stype == "foto" OR $stype == "alt") {
opentable('Søgeresultater i fotoalbums titel og tekst');

// search in album's title and text

$sql = dbquery("SELECT *
FROM ".$fusion_prefix."photo_albums
WHERE album_title LIKE '%".$query."%'
OR album_info LIKE '%".$query."%'
" );
$rows = dbrows($sql);
if (!isset($rowstart)) $rowstart = 0;
if ($rows != 0) {
$sql = dbquery("SELECT *
FROM ".$fusion_prefix."photo_albums
WHERE album_title LIKE '%".$query."%'
OR album_info LIKE '%".$query."%'
LIMIT $rowstart,10");
while ($data = dbarray($sql)) {


if (eregi($query, $data['album_title'])) {
echo "<img src='".FUSION_THEME."images/bullet.gif'> <a href='photogallery.php?album=".$data['album_id']."'>".parsesearch($data['album_title'],$query)."</a><br>\n";
echo $data['album_info']."<br><br>";}

if (eregi($query, $data['album_info'])) {
echo "<img src='".FUSION_THEME."images/bullet.gif'> <a href='photogallery.php?album=".$data['album_id']."'>".$data['album_title']."</a><br>\n";

echo parsesearch(stripslashes($data['album_info']),$query)."<br><br>\n";



//echo "<br>";
}

}


} else {
echo "<center><br>\n".LAN_440."<br><br>\n</center>\n";
}
closetable();
echo "<div align='center' style='margin-top:5px;'>\n".makePageNav($rowstart,10,$rows,3,"$PHP_SELF?stype=foto&stext=$stext&")."\n</div>\n";

}


// søgning i fotoalbums billedtekst _____________________
// Search in photo titles

if ($stype == "foto" OR $stype == "alt") {
opentable('Søgeresultater i billedtitler');

$sql = dbquery("SELECT *
FROM ".$fusion_prefix."photo_albums, ".$fusion_prefix."photos
WHERE (photo_title LIKE '%".$query."%'
AND ".$fusion_prefix."photo_albums.album_id = ".$fusion_prefix."photos.album_id)
" );
$rows = dbrows($sql);
if (!isset($rowstart)) $rowstart = 0;
if ($rows != 0) {
$sql = dbquery("SELECT * FROM ".$fusion_prefix."photo_albums, ".$fusion_prefix."photos
WHERE (photo_title LIKE '%".$query."%' AND ".$fusion_prefix."photo_albums.album_id = ".$fusion_prefix."photos.album_id)
LIMIT $rowstart,10");
while ($data = dbarray($sql)) {


if (eregi($query, $data['photo_title'])) {
echo "<img src='".FUSION_THEME."images/bullet.gif'> <a href='photogallery.php?photo=".$data['photo_id']."'>".$data['album_title']."</a><br>\n";

echo parsesearch(stripslashes($data['photo_title']),$query)."<br>\n";

echo "<br>";
}

}


} else {
echo "<center><br>\n".LAN_440."<br><br>\n</center>\n";
}
closetable();
echo "<div align='center' style='margin-top:5px;'>\n".makePageNav($rowstart,10,$rows,3,"$PHP_SELF?stype=foto&stext=$stext&")."\n</div>\n";

}


// søgning i fotoalbums kommentarer ___________________
// Search in comments to photos

if ($stype == "foto" OR $stype == "alt") {
opentable('Søgeresultater i billedkommentarer');

$sql = dbquery("SELECT *
FROM ".$fusion_prefix."photo_albums, ".$fusion_prefix."photos, ".$fusion_prefix."comments
WHERE (comment_message LIKE '%".$query."%'
AND ".$fusion_prefix."photo_albums.album_id = ".$fusion_prefix."photos.album_id
AND ".$fusion_prefix."comments.comment_item_id = ".$fusion_prefix."photos.photo_id
AND ".$fusion_prefix."comments.comment_type='P')
" );
$rows = dbrows($sql);
if (!isset($rowstart)) $rowstart = 0;
if ($rows != 0) {
$sql = dbquery("SELECT *
FROM ".$fusion_prefix."photo_albums, ".$fusion_prefix."photos, ".$fusion_prefix."comments
WHERE (comment_message LIKE '%".$query."%'
AND ".$fusion_prefix."photo_albums.album_id = ".$fusion_prefix."photos.album_id
AND ".$fusion_prefix."comments.comment_item_id = ".$fusion_prefix."photos.photo_id
AND ".$fusion_prefix."comments.comment_type='P')
LIMIT $rowstart,10");
while ($data = dbarray($sql)) {


if (eregi($query, $data['comment_message'])) {
echo "<img src='".FUSION_THEME."images/bullet.gif'> <a href='photogallery.php?photo=".$data['photo_id']."'>".$data['album_title']."</a><br>\n";

echo parsesearch(stripslashes($data['comment_message']),$query)."<br>\n";

echo "<br>";
}

}


} else {
echo "<center><br>\n".LAN_440."<br><br>\n</center>\n";
}
closetable();
echo "<div align='center' style='margin-top:5px;'>\n".makePageNav($rowstart,10,$rows,3,"$PHP_SELF?stype=foto&stext=$stext&")."\n</div>\n";

}





// søgning i debatforum ______________________________
// search in forum (no chages):

if ($stype == "fp" OR $stype == "alt") {
opentable('Søgeresultater i debatforum');
$sql = dbquery(
"SELECT tp.*, tf.* FROM ".$fusion_prefix."posts tp
INNER JOIN ".$fusion_prefix."forums tf USING(forum_id)
WHERE forum_access<=".iUSER." AND post_subject LIKE '%".$query."%' OR post_message LIKE '%".$query."%'"
);
$rows = dbrows($sql);
if (!isset($rowstart)) $rowstart = 0;
if ($rows != 0) {
$sql = dbquery(
"SELECT tp.*, tf.* FROM ".$fusion_prefix."posts tp
INNER JOIN ".$fusion_prefix."forums tf USING(forum_id)
WHERE forum_access<=".iUSER." AND post_subject LIKE '%".$query."%' OR post_message LIKE '%".$query."%'
ORDER BY post_datestamp DESC LIMIT $rowstart,10"
);
while ($data = dbarray($sql)) {
$numrows = dbcount("(post_id)", "posts", "thread_id='".$data['thread_id']."' AND post_id<'".$data['post_id']."'");
if ($numrows > 20) {
$rstart = ceil($numrows / 20);
$rstart = "rowstart=".(($rstart-1)*20)."&";
} else {
$rstart = "";
}
if (eregi($query, $data['post_subject']) && eregi($query, $data['post_message'])) {
echo "<img src='".FUSION_THEME."images/bullet.gif'> <a href='".FUSION_FORUM."viewthread.php?".$rstart."forum_id=".$data['forum_id']."&thread_id=".$data['thread_id']."#".$data['post_id']."'>".parsesearch($data['post_subject'],$query)."</a><br>\n";
echo parsesearch(stripslashes($data['post_message']),$query)."<br>\n";
echo "<img src='".FUSION_THEME."images/bullet.gif'> <span class='small2'>".LAN_420.LAN_428.LAN_421.LAN_429.LAN_422.showDate("longdate", $data['post_datestamp']).".</span><br><br>\n";
} else if (eregi($query, $data['post_subject'])) {
echo "<img src='".FUSION_THEME."images/bullet.gif'> <a href='".FUSION_FORUM."viewthread.php?".$rstart."forum_id=".$data['forum_id']."&thread_id=".$data['thread_id']."#".$data['post_id']."'>".parsesearch($data['post_subject'],$query)."</a><br>\n";
echo trimlink(stripslashes($data['post_message']),100)."<br>\n";
echo "<img src='".FUSION_THEME."images/bullet.gif'> <span class='small2'>".LAN_420.LAN_428.LAN_422.showDate("longdate", $data['post_datestamp']).".</span><br><br>\n";
} else if (eregi($query, $data['post_message'])) {
echo "<img src='".FUSION_THEME."images/bullet.gif'> <a href='".FUSION_FORUM."viewthread.php?".$rstart."forum_id=".$data['forum_id']."&thread_id=".$data['thread_id']."#".$data['post_id']."'>".$data['post_subject']."</a><br>\n";
echo parsesearch(stripslashes($data['post_message']),$query)."<br>\n";
echo "<img src='".FUSION_THEME."images/bullet.gif'> <span class='small2'>".LAN_420.LAN_429.LAN_422.showDate("longdate", $data['post_datestamp']).".</span><br><br>\n";
}
}
} else {
echo "<center><br>\n".LAN_440."<br><br>\n</center>\n";
}
closetable();
echo "<div align='center' style='margin-top:5px;'>\n".makePageNav($rowstart,10,$rows,3,"$PHP_SELF?stype=fp&stext=$stext&")."\n</div>\n";
}
} else {
opentable(LAN_403);
echo "<center><br>\n".LAN_441."<br><br>\n</center>\n";
closetable();
}
}

function parsesearch($text,$match) {
$text = strip_tags($text);
$aft = stristr($text,$match);
$pos = strlen($text)-strlen($aft);
if ($pos < 50) { $text = "..".substr($text, 0, 100).".."; } else { $text = "..".substr($text, ($pos-50), 100).".."; }
$text = eregi_replace($match, "<span style='font-weight:bold;color:#000;background-color:#eeee00;'>".$match."</span>", $text);
return $text;
}

echo "</td>\n";

require_once "side_right.php";
require_once "footer.php";
?>





Det der skal søges efter i db er:

dvdinfos_name
dvdinfos_description
dvdinfos_nr

Håber der er en der vil hjælpe mig...Plz :(
Avatar billede esbar Nybegynder
19. maj 2005 - 22:21 #1
Hmm. Det var en ordenlig bunke kode. Hvad med at poste et link så vi kan arbejde ud fra det?
Avatar billede crapmaster Nybegynder
19. maj 2005 - 22:28 #2
Jeg er ikke helt med, skal du have en side hvor du kan se den virke.
Avatar billede crapmaster Nybegynder
19. maj 2005 - 22:33 #3
Problemmet er at jeg vil have pillet de ting ud at den for at bruge den til min dvddatabase, der i er der 3 ting den skal søge efter,

Tabelen i db hedder ( fusion_dvdinfos )

dvdinfos_name
dvdinfos_nr
dvdinfos_description
Avatar billede crapmaster Nybegynder
24. november 2005 - 07:12 #4
//Lukker da der ingen svar kommer
Avatar billede crapmaster Nybegynder
24. november 2005 - 07:13 #5
//Lukker
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester