Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

Search Panel

Asked Modified Viewed 9,784 times
M
Mike77
M
Mike77 10
  • Junior Member, joined since
  • Contributed 16 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions
asked
Junior Member

I want to create a panel with advanced search options. I want to search only title and results containing all these words, and may select only certain words set me. I attached a picture of what I want .. I do not know php very well. If you can help me...

thanks
Mike77 attached the following file:
capture_1.jpg [No information available / 88 Downloads]
0 replies

31 posts

C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,842 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

This is a search panel for searching what?
0 replies
M
Mike77
M
Mike77 10
  • Junior Member, joined since
  • Contributed 16 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions
answered
Junior Member

i want to choose what I want to search
for example: i want to choose to search
2 bedroom apartment in different zone, but i want to do that with simple click to choose:

i need to can choose: selling or renting
studio, apartament, house
if is apartament 2,3,4 or 5 beedroms.
neighborhood (and 6 options here too)

I make a foto gallery with some offerts, and this words selling, renting, studio etc will find in title of photo album.

I want to search an offer, and this offer can be a selling of apartament or renting a house

Merged on May 01 2013 at 15:34:39:
I do a html example, maybe you will understand better.
Edited by Mike77 on 01-05-2013 16:35,
Mike77 attached the following file:
capture_2.jpg [No information available / 81 Downloads]
0 replies
C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,842 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

So you want to alter the photo gallery to search on the criterial above, you need to have the fields added to your gallery SQL tables. But first how you want to organize your listing?

Lets say, photo has categories yes? What you think those categories will be? You cannot add photos until you add categories. Mind this, if you are dedicating the entire site for real estate only, we can mod straight the gallery with new attributes you need. But it will be awkward to say if you also want to add holidays attraction it is not suitable to mod the gallery. We need to dump every picture into one folder and sort it through a new SQL table we will create.

I will not spoon feed, I will teach you how to do it so you can learn Php.

My question is, will the entire photo gallery be used for one purpose only or not?
Option A. No other photos except apartments.
Option B. maybe will have other photos not related to apartments like beach, sunset, shopping.
0 replies
M
Mike77
M
Mike77 10
  • Junior Member, joined since
  • Contributed 16 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions
answered
Junior Member

Not that complicated... i don't want to change the photogallery.
When I add a photo album, in title of album I write the information there : For selling apartament 2 bedrooms in Marasti, so I want to search the exact words in title of photo gallery or in all the site, don't metter (selling apartament 2 bedrooms Marasti)
0 replies
C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,842 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

Lol. Ok. Code me your HTML here, I will php it for you. Remember, the way you want the drop down is specified, not dynamic. Meaning, you will need to edit the HTML yourself next time if your search criteria changes.

Merged on May 02 2013 at 02:37:13:
Just paste in your entire HTML

Merged on May 02 2013 at 03:54:20:
I do not know if it is what you want, but you can configure it based on few things:

1. I set search on Articles. Because article has snippet. You can put your full sentence there - ie meta. If you want to modify, try it yourself.. open the maincore, find the definition for tables there. i.e DB_something is which table. Remember, you did not specify which table to use, I just pick one for you. There is no site-wide searching because your specific needs was not specified. My aim is therefore, teach you php-fusion.

2. The most bottom is to search on the article_snippet inside the article field. Just add the photo inside the article, as cosmetics. If you want to do it in photos, then change ".DB_ARTICLES." to ".DB_PHOTOS." and the field is photo_description.. search is text sensitive, if you use the word "RENT".. then it will pop as result.

3. Things to learn, your homework. what is Echo. The relationship between ' and " in php.

4. SQL query statement. We use dbquery(), dbrows(), dbcount(), dbarray(). 4-kings-cards. I have shown you a full blown example of things.. you check it out.

5. In html, you use "<html> and </html>" in, php you use <?php and ?> In w3 documentation, you can do it this way:


<html>

<?php ... phpcode here... ?>

</html>


But in PHPFusion, we do it this way

<?php

echo " simply type html here ";

?>


That should kick start your project. I know it is important to you.

Now, my example. You need 2 page. create a php document for each.
store it inside a folder or root, just change path in form action.

Again, I am typing this using my wife's pc... so I do not know if it works, It should, but if there's a bug, we'll fix it. Just tell.

With this example, you drop down should not be empty so first option cannot be disabled or <value=''> blank.


/* PAGE OUTPUT */ - NEWPAGE
<?php

// Prevent Cross Site XSS Scripting input
function sanitize($string) {
    return mysql_real_escape_string($string);
}
// Prevent Cross Site XSS scripting output
function clean($output) {
return htmlspecialchars($output);
}


IF ($_POST['earth'])  {

$mars = sanitize($_POST['mars']);
$venus = sanitize($_POST['venus']);
$uranus = sanitize($_POST['uranus']);
$jupiter = sanitize($_POST['jupiter']);
$sun = sanitize($_POST['sun']);
$moon = sanitize($_POST['moon']);

$full_sentence = "$mars $venus $uranus $jupiter $sun $moon";

$result = dbquery("SELECT * FROM ".DB_ARTICLES." WHERE articles_snippet LIKE '%".$full_sentence."' ORDER BY article_datestamp ASC");
$rows = dbrows($result);

opentable("Your page search results yield: $rows number of results..");
echo "<ul>\n";

while ($data = dbarray($result)) {
// CHECK FROM YOUR _articles table what you need..
$article_subject = clean($data['article_subject']);
$article_article= clean($data['article_subject']);
$article_datestamp= clean($data['article_subject']);
$article_reads= clean($data['article_subject']);
echo "<li> $article_subject, $article_article, $article_datestamp, $article_reads</li>\n";
}

echo "</ul>\n";
closetable();
}

?>

/* PAGE INPUT */ -- NEW PAGE

<?php
// remember to use ' instead of " because we open echo with ", inside must be '  if you open echo with ' then inside is "
// search internet to differentiate between ' and " in php. It's simple.
echo "
<form name='inputform' method='post' action='page2.php'>
<table width='100%'>
<tr><td>I want to : </td><td> <select name='mars'><option>rent</option></select> </td></tr>
<tr><td><input type='button' name='earth' value='Search My Home'></td></tr>
</table>
</form>
";
?>


Merged on May 02 2013 at 03:58:40:
Link to read:

With forms, you need sanitization. It's VERY dangerous without because if you let outsiders script hack in, your site is gone in 1 sec.

http://stackoverflow.com/questions/3126072/what-are-the-best-php-input-sanitizing-functions
Edited by Chan on 02-05-2013 05:00,
0 replies
M
Mike77
M
Mike77 10
  • Junior Member, joined since
  • Contributed 16 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions
answered
Junior Member

OK. I made this

// remember to use ' instead of " because we open echo with ", inside must be '  if you open echo with ' then inside is "
// search internet to differentiate between ' and " in php. It's simple.
echo "
<form name='inputform' method='post' action='page2.php'>
<table width='50%'>
<tr><td>Tip Tranzactie : </td><td> <select name='mars'><option> </option><option>de vanzare</option><option>de inchiriat</option></select> </td></tr>
<tr><td>Tip Imobil: </td><td> <select name='venus'><option> </option><option>garsoniera</option><option>apartament 1 camera</option><option>apartament 2 camere</option><option>apartament 3 camere</option><option>apartament 4 camere</option><option>apartament 5 camere</option><option>casa</option><option>teren</option><option>spatiu comercial</option></select> </td></tr>
<tr><td>Cartier: </td><td> <select name='uranus'><option> </option><option>Andrei Muresanu</option><option>Borhanci</option><option>Bulgaria</option><option>Buna Ziua</option><option>Central</option><option>Dambu Rotund</option><option>Europa</option><option>Faget</option><option>Gara</option><option>Gheorgheni</option><option>Grigorescu</option><option>Gruia</option><option>Intre Lacuri</option><option>Iris</option><option>Manastur</option><option>Marasti</option><option>Plopilor</option><option>Someseni</option><option>Zorilor</option></select> </td></tr>
<tr><td><input type='button' name='earth' value='Cauta'></td></tr>
</table>
</form>
";
?>


Almost OK when i preview the panel look's something like this: {first foto} and when i save the panel look's different {2 foto}

And when i press the button "cauta" doesnt make "the search"...

page2.php


<?php

// Prevent Cross Site XSS Scripting input
function sanitize($string) {
    return mysql_real_escape_string($string);
}
// Prevent Cross Site XSS scripting output
function clean($output) {
return htmlspecialchars($output);
}


IF ($_POST['earth'])  {

$mars = sanitize($_POST['mars']);
$venus = sanitize($_POST['venus']);
$uranus = sanitize($_POST['uranus']);

$full_sentence = "$mars $venus $uranus";

$result = dbquery("SELECT * FROM ".DB_ARTICLES." WHERE articles_snippet LIKE '%".$full_sentence."' ORDER BY article_datestamp ASC");
$rows = dbrows($result);

opentable("Your page search results yield: $rows number of results..");
echo "<ul>\n";

while ($data = dbarray($result)) {
// CHECK FROM YOUR _articles table what you need..
$article_subject = clean($data['article_subject']);
$article_article= clean($data['article_subject']);
$article_datestamp= clean($data['article_subject']);
$article_reads= clean($data['article_subject']);
echo "<li> $article_subject, $article_article, $article_datestamp, $article_reads</li>\n";
}

echo "</ul>\n";
closetable();
}

?>


I don't undertstand the last part what that do...

while ($data = dbarray($result)) {
// CHECK FROM YOUR _articles table what you need..
$article_subject = clean($data['article_subject']);
$article_article= clean($data['article_subject']);
$article_datestamp= clean($data['article_subject']);
$article_reads= clean($data['article_subject']);
echo "<li> $article_subject, $article_article, $article_datestamp, $article_reads</li>\n";
Mike77 attached the following file:
1_3.jpg [No information available / 59 Downloads]
2_1.jpg [No information available / 59 Downloads]
0 replies
C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,842 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

Ok, first we troubleshoot the panel.
If you want to do it in create new panel, use the


openside("This is where your title goes");

echo "
<form name='inputform' method='post' action='"BASEDIR."search_home.php'>
<table width='50%'>
<tr><td>Tip Tranzactie : </td><td> <select name='mars'><option> </option><option>de vanzare</option><option>de inchiriat</option></select> </td></tr>
<tr><td>Tip Imobil: </td><td> <select name='venus'><option> </option><option>garsoniera</option><option>apartament 1 camera</option><option>apartament 2 camere</option><option>apartament 3 camere</option><option>apartament 4 camere</option><option>apartament 5 camere</option><option>casa</option><option>teren</option><option>spatiu comercial</option></select> </td></tr>
<tr><td>Cartier: </td><td> <select name='uranus'><option> </option><option>Andrei Muresanu</option><option>Borhanci</option><option>Bulgaria</option><option>Buna Ziua</option><option>Central</option><option>Dambu Rotund</option><option>Europa</option><option>Faget</option><option>Gara</option><option>Gheorgheni</option><option>Grigorescu</option><option>Gruia</option><option>Intre Lacuri</option><option>Iris</option><option>Manastur</option><option>Marasti</option><option>Plopilor</option><option>Someseni</option><option>Zorilor</option></select> </td></tr>
<tr><td><input type='button' name='earth' value='Cauta'></td></tr>
</table>
</form>
";

closeside();



Next:

The reason "cauta" does not search is because form action is not going to where it is supposed to be. Also, I see that there is a portion i left out earlier. I typed it out in the forum, and I was running out of time to work this morning.

I'm attaching a file... it's a revision of code for page 2 with basically this. But just download it.


<?php
require_once "maincore.php";
require_once THEMES."templates/header.php";

// Prevent Cross Site XSS Scripting input
function sanitize($string) {
    return mysql_real_escape_string($string);
}
// Prevent Cross Site XSS scripting output
function clean($output) {
return htmlspecialchars($output);
}

IF ($_POST['earth'])  {

$mars = sanitize($_POST['mars']);
$venus = sanitize($_POST['venus']);
$uranus = sanitize($_POST['uranus']);
$jupiter = sanitize($_POST['jupiter']);
$sun = sanitize($_POST['sun']);
$moon = sanitize($_POST['moon']);

$full_sentence = "$mars $venus $uranus $jupiter $sun $moon";

$result = dbquery("SELECT * FROM ".DB_ARTICLES." WHERE articles_snippet LIKE '%".$full_sentence."' ORDER BY article_datestamp ASC");
$rows = dbrows($result);

if (dbrows($result) >= "1") {
opentable("Your page search results yield: $rows number of results..");
echo "<table width='100%'>\n";

while ($data = dbarray($result)) {
    // CHECK FROM YOUR _articles table what you need..
    $article_subject = clean($data['article_subject']);
    $article_article= clean($data['article_subject']);
    $article_datestamp= clean($data['article_subject']);
    $article_reads= clean($data['article_subject']);
 
  // Format your output beautifully in css here.
                                                                                                                                                           
  echo "<tr><td>
  This is the subject= $article_subject
  <br>
  This is the article= $article_article </td></tr>\n";
 
  }
echo "</table>\n";
closetable();
  } else {
    opentable("No Result");
    echo "Sorry there is no result from your search.";
    closetable();
  }
}


require_once THEMES."templates/footer.php";
?>


Open up your FTP, and upload it to your phpfusion root directory, where search.php, config.php, maincore.php is. Important you upload to correct position.

I revised both files. Panel and Output.


Try and tell me if it is working. Also it will help if i can see your live site because I need to view your source.
Edited by Chan on 02-05-2013 13:47,
Chan attached the following file:
search_home.rar [No information available / 428 Downloads]
0 replies
M
Mike77
M
Mike77 10
  • Junior Member, joined since
  • Contributed 16 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions
answered
Junior Member

www.class-imobiliare.ro here you will see live.

If i used openside i get the error :"Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/class/public_html/administration/panel_editor.php(153) : eval()'d code on line 4"

I upload in the root directory the file search_home.php but still nothing..
0 replies
C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,842 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

Its in the center. change.


opentable("title goes here");

closetable();


Merged on May 02 2013 at 13:24:06:
And typo error sorry..


<form name='inputform' method='post' action='".BASEDIR."search_home.php'>


Merged on May 02 2013 at 13:25:35:
Mind, create an article with the text specified. It searches the snippet.
Edited by Chan on 02-05-2013 14:25,
0 replies
M
Mike77
M
Mike77 10
  • Junior Member, joined since
  • Contributed 16 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions
answered
Junior Member

I have the article "De vanzare apartament 2 camere in cartier Buna Ziua" and i want to search "de vanzare apartament 2 camere Buna Ziua" but i want to search in photogallery because there is my offert...

while ($data = dbarray($result)) {
    // CHECK FROM YOUR _articles table what you need..
    $article_subject = clean($data['article_subject']);
    $article_article= clean($data['article_subject']);
    $article_datestamp= clean($data['article_subject']);
    $article_reads= clean($data['article_subject']);
 


i think here is the problem...it is not article no? it is a photo album...
0 replies
C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,842 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

Post function is still not working. rename search_home.php to shome.php change the action again. see if it redirects on click.

We sort out the data later. it's more important to get the form to work first. SQL can be done fast.

Merged on May 02 2013 at 16:42:14:

<input type='button' name='earth' value='Cauta'>


to


<input type='submit' name='earth' value='Cauta'>



Should work. and will get no result. If you're working on photogallery album, which field are you searching? the title? the description?
Edited by Chan on 02-05-2013 17:45,
0 replies
M
Mike77
M
Mike77 10
  • Junior Member, joined since
  • Contributed 16 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions
answered
Junior Member

work now :) but not find anything

Merged on May 02 2013 at 16:53:13:
Unknown column 'articles_snippet' in 'where clause'
No Result
Sorry there is no result from your search.

I search in title
0 replies
C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,842 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

See my post above smile

Quote


Should work. and will get no result. If you're working on photogallery album, which field are you searching? the title? the description?


I see you use title as grine vanzare apartament 2 camere in cartier Buna Ziua

And the search string is to detect this right?
Edited by Chan on 02-05-2013 18:20,
0 replies
M
Mike77
M
Mike77 10
  • Junior Member, joined since
  • Contributed 16 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions
answered
Junior Member

Yes , I want to detect what is in title..
0 replies
C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,842 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

Give me a minute. I'll work out another file to replace shome.php and you're good to go.
Edited by Chan on 02-05-2013 18:18,
0 replies
M
Mike77
M
Mike77 10
  • Junior Member, joined since
  • Contributed 16 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions
answered
Junior Member

Ok
0 replies
C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,842 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin



Ok, uploaded. Delete the old one, and replace this one.
Chan attached the following file:
shomephp.zip [No information available / 420 Downloads]
0 replies
M
Mike77
M
Mike77 10
  • Junior Member, joined since
  • Contributed 16 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions
answered
Junior Member

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/class/public_html/shome.php on line 51
0 replies
C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,842 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

Saw it, sorry i missed a dot. reupload.
Chan attached the following file:
shomephp_1.zip [No information available / 405 Downloads]
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 31 posts
  • Votes 0 votes
  • Topic users 2 members

2 participants

C
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,842 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
M
M
Mike77 10
  • Junior Member, joined since
  • Contributed 16 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet