Site Search Store Search Term

3 posts by 2 authors in: Forums > CMS Builder
Last Post: February 4, 2013   (RSS)

By KCMedia - February 4, 2013

I have a search function built and working on the site but i want to store the search terms that someone types into the search box on the site can someone help with how i would go about this, here is the search forms and the results below in the code.

                        <article class="main-content">
                            <h1>Search results for <?php echo htmlspecialchars(@$FORM['search_terms']); ?></h1>
                            <div class="main-search rel fl">
                            <form method="GET" action="<?php echo $_SERVER['PHP_SELF']; ?>" >
                            <input type="text" name="search_terms" value="<?php echo htmlspecialchars(@$FORM['q']); ?>">
                            <button type="submit"><span class="ir">Seach</span></button>
                            </form>
                            </div><br><br>
                            <h2>Results <?php echo htmlspecialchars(@$searchDetails['pageResultsStart']); ?> to <?php echo htmlspecialchars(@$searchDetails['pageResultsEnd']); ?> of <?php echo htmlspecialchars(@$searchDetails['totalRecords']); ?>.</h2>
                            
                            <!-- show errors -->
                            <?php if ($searchDetails['invalidPageNum']): ?>
                              Results page '<?php echo $searchDetails['page']?>' not found, <a href="<?php echo $searchDetails['firstPageLink'] ?>">start over &gt;&gt;</a>.<br/>
                            <?php elseif ($searchOptions['keywords'] && $searchDetails['noRecordsFound']): ?>
                              No records matched search query!<br/>
                            <?php elseif ($searchOptions['keywords'] == ""): ?>
                              Enter a keyword to search.<br/>
                            <?php endif ?><br>
                            
                            <!-- STEP2: Display Record List -->
                              
                              <ul style="list-style-type:none; list-style:none; margin-left:0; margin-top:0">
                              <?php foreach ($searchRows as $record): ?>
                                 <li style="min-height: 100px;">
                                 <h4><a href="<?php echo $record['_link'] ?>"><?php echo $record['_title'] ?></a></h4>
                                 <span style="color:#F00; font-style:italic"><?php echo $record['_link'] ?></span><br>
                                 <?php if ($record['_summary']): ?>
                                   <?php $maxWords = 40; $words = explode(" ", $record['_summary']); $words = array_slice($words, 0, $maxWords); $summary = join(" ", $words); print $summary; ?>
                                  <?php else: ?>
                                    <br/>
                                 </li>
                                  <?php endif ?>
                              <?php endforeach ?><br><br>
                              </ul>
                            <!-- /STEP2: Display Record List -->

                            <!-- STEP3: Display Page Links (Paste anywhere below "Load Record List") -->
                              <?php if ($searchDetails['prevPage']): ?>
                                 <a href="<?php echo $searchDetails['prevPageLink'] ?>">&lt;&lt; prev</a>
                                 <?php else: ?>
                                  &lt;&lt; prev
                                 <?php endif ?>

                                    - page <?php echo $searchDetails['page'] ?> of <?php echo $searchDetails['totalPages'] ?> -

                                 <?php if ($searchDetails['nextPage']): ?>
                                 <a href="<?php echo $searchDetails['nextPageLink'] ?>">next &gt;&gt;</a>
                                 <?php else: ?>
                                  next &gt;&gt;
                                 <?php endif ?>
                            <!-- /STEP3: Display Page Links -->
                            

                        </article><!-- /main-content -->

Thanks



Craig

KC Media Solutions

www.kcmedia.biz

By KCMedia - February 4, 2013

Hi Greg

perfect thank you very much works great.

Thanks



Craig

KC Media Solutions

www.kcmedia.biz