problem with multisearch
12 posts by 4 authors in: Forums > CMS Builder
Last Post: February 23, 2011 (RSS)
By hordak - February 23, 2011
Hey Jason,
Thanks for the advice. I'm currently working between both the Basic Search Code and Multi-search code as supplied. I'm having a problem with the output, because my searchDetails Variable is not resolving (line 48).
Also, My search form is posting all records without a keyword.
- Multisearch doesn't supply necessary fields
see http://www.centralstate.edu/services/contact/_includes/multiSearch.php (try keywords Dean and then giraffe)
- My simple search is kicking back the errors as specified
see http://www.centralstate.edu/services/contact/_includes/search-self.php (try keywords Dean and then giraffe)
What should I do?
Thanks for the advice. I'm currently working between both the Basic Search Code and Multi-search code as supplied. I'm having a problem with the output, because my searchDetails Variable is not resolving (line 48).
Also, My search form is posting all records without a keyword.
- Multisearch doesn't supply necessary fields
see http://www.centralstate.edu/services/contact/_includes/multiSearch.php (try keywords Dean and then giraffe)
- My simple search is kicking back the errors as specified
see http://www.centralstate.edu/services/contact/_includes/search-self.php (try keywords Dean and then giraffe)
What should I do?
<?php
require_once "/home/cmsAdmin/lib/viewer_functions.php";
$searchOptions = array();
$searchOptions['keywords'] = @$FORM['q'];
$searchOptions['perPage'] = "10";
$searchOptions['debugSql'] = "1";
list($sv_campus_directoryRecords, $sv_campus_directoryMetaData) = getRecords(array(
'tableName' => 'sv_campus_directory',
'perPage' => '3',
));
?>
<!-- /STEP1: Load Record List -->
<div class="container">
<div class="top"><strong><span class="text_maroon">Search CSU Departments</span></strong></div>
<div class="OneColumn">
<form method="GET" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<!--<form method="POST" action="search.php?department_keyword">-->
<input type="text" name="q" value="<?php echo htmlspecialchars(@$FORM['q']); ?>">
<input type="submit" name="" value="Search">
</form>
<?php if ($sv_campus_directoryRecords): ?>
<table border=0 cellpadding=2 cellspacing=0 width=100%>
<tr>
<td bgcolor="#EEEEEE"><span class="text">Search results for <strong><?php echo htmlspecialchars(@$FORM['q']); ?></strong></span></td>
<td bgcolor="#EEEEEE" align="right"><span class="text">Results
<b><?php echo htmlspecialchars($sv_campus_directoryMetaData['pageResultsStart']); ?></b> to
<b><?php echo htmlspecialchars($sv_campus_directoryMetaData['pageResultsEnd']); ?></b> of
<b><?php echo htmlspecialchars($sv_campus_directoryMetaData['totalRecords']); ?></b>.</span></td>
</tr>
</table>
<br clear="all" />
<!-- show errors -->
<?php if ($sv_campus_directoryMetaData['invalidPageNum']): ?>
<span class="text">Results page '<?php echo $searchDetails['page']?>' not found, <a href="<?php echo $searchDetails['firstPageLink'] ?>">start over >></a>.</span><br/>
<?php elseif ($searchOptions['keywords'] && $searchDetails['noRecordsFound']): ?>
<span class="text">No records matched search query!</span><br/>
<?php elseif ($searchOptions['keywords'] == ""): ?>
<span class="text">Enter a keyword to search.</span><br/>
<?php endif ?>
<!-- show errors -->
<br>
<!-- STEP2: Display Records (Paste this where you want your records to be listed) -->
<?php foreach ($sv_campus_directoryRecords as $record): ?>
<span class="text">
<strong><?php echo $record['department'] ?></strong>
<?php if ($record['url']): ?>
| <a href="<?php echo $record['url'] ?>" target="_blank">Visit Website</a>
<?php endif ?>
<br/>
Phone: <?php echo $record['phone'] ?><br/>
Fax: <?php echo $record['fax'] ?><br/>
Email: <?php echo $record['email'] ?><br/>
</span>
<hr size="1"/>
<?php endforeach ?>
<!-- /STEP2: Display Records -->
<!-- STEP3: Display Page Links (Paste anywhere below "Load Record List") -->
<?php if ($sv_campus_directoryMetaData['prevPage']): ?>
<span class="text"><a href="<?php echo $sv_campus_directoryMetaData['prevPageLink'] ?>">.:. prev</a></span>
<?php else: ?>
<span class="text" style="color:#999;">.:. prev</span>
<?php endif ?>
<span class="text">- page <?php echo $sv_campus_directoryMetaData['page'] ?> of <?php echo $sv_campus_directoryMetaData['totalPages'] ?> -</span>
<?php if ($sv_campus_directoryMetaData['nextPage']): ?>
<span class="text"><a href="<?php echo $sv_campus_directoryMetaData['nextPageLink'] ?>">next .:.</a>
<?php else: ?>
<span class="text" style="color:#999;">next .:.</span>
<?php endif ?>
<!-- /STEP3: Display Page Links -->
<?php endif ?>
<?php if (!$sv_campus_directoryRecords): ?>
<?php endif ?>
</div>
</div>
Re: [hordak] problem with multisearch
By Jason - February 23, 2011
Hi,
You're not going to be able to combine the code from these two types of search very well since they work completely differently. The error is coming from the fact that in your code, you're never defining a variable called $searchDetails, but you are trying to use it to output information.
Here are some things to help. First, remove any code that comes from the MultiSearch. For example:
Next, you'll need to rename your form field to match the names of the section fields you want to search on. For example, if you wanted to search against fields called title and content, you would name your field like this:
Finally, when outputting you're records, use $sv_campus_direcotryRecords for your foreach loop. This is the variable that will hold all of your results.
Hope this helps get you started.
You're not going to be able to combine the code from these two types of search very well since they work completely differently. The error is coming from the fact that in your code, you're never defining a variable called $searchDetails, but you are trying to use it to output information.
Here are some things to help. First, remove any code that comes from the MultiSearch. For example:
$searchOptions = array();
$searchOptions['keywords'] = @$FORM['q'];
$searchOptions['perPage'] = "10";
$searchOptions['debugSql'] = "1";
Next, you'll need to rename your form field to match the names of the section fields you want to search on. For example, if you wanted to search against fields called title and content, you would name your field like this:
<input type="text" name="title,content_keywords" value="<?php echo htmlspecialchars(@$_REQUEST['title,content_keywords']); ?>">
Finally, when outputting you're records, use $sv_campus_direcotryRecords for your foreach loop. This is the variable that will hold all of your results.
Hope this helps get you started.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/