Basically I want to know how loop through to show multiple results. So far only 1 record is being returned to my website page even when there is more then one match.Also how would I go about allowing a user to Select a check box as an input?One more issue..the registration form that create the table (this table is then searched by the above form) has some issues. I have a problem with saving check box values into my database. On events I have Supported_Consoles[] in the Handle Array section. This corresponds to (note that the supported_console_id changes for every checkbox I have.)For example, if I check PS3 and XBOX360 checkbox it shows the following in the database: PS3 Supported_Games[]XBOX360 . Why would it be showing the 'supported_Games[]' for? Any solution for this!Thank you! (sorry about the long post🙂"> Chronoform Database Searching and returning - Forums

Forums

Chronoform Database Searching and returning

JakeI 27 May, 2012
Hello, I'm new to chronoforms and have been playing around with a form that will search a database and return specific results based on user input fields.

In the Preview section I have code in the Custom Element Box:
<table border="0" width="100%" id="table1">
      <tr>
        <td align="center"> </td>
        <td width="119" align="center">
          <label align="left">
            Console: <input type="text" name="keyword" size="33" class="text">
 Games:  <input type="text" name="keyword2" size="33" class="text">
          </label>
          <input type=submit value="Search" style="color: #6A0204; font-family: verdana; font-weight: normal; font-size:10px; background-color: #FFFFFF; float:center;" name="search">
        </td>
        <td width="30"> </td>
      </tr>
    </table>


Then for events I have On Load section, show html and on Submit I have Custom Code which is:

<?php
$db =& JFactory::getDBO();
$keyword = JRequest::getString('keyword', '', 'post');
$keyword2 = JRequest::getString('keyword2', '', 'post');
if ( $keyword OR $keyword2 ) {
  $sql="
    SELECT *
      FROM `#__chronoforms_data_SponsorRegistration`
      WHERE `Supported_Consoles` LIKE '%$keyword%' OR 'Supported_Games' LIKE '%$keyword2%' 
      ORDER BY `cf_id` DESC";
$db->setQuery($sql);
/*echo '<div>$sql: '.print_r($sql, true).'</div>';*/
$results = $db->loadRowList();
/*echo '<div>$results: '.print_r($results, true).'</div>';*/


foreach ($results as $result ); 
{

  echo "First Name: " .$result [6]."<br />";
  echo "Last_Name: " .$result [7]."<br />";
  echo "Supported Games: " .$result [15]."<br />";
  echo "Supported Consoles: " .$result [8]."<br />";
  echo "Organistation or Company: " .$result [9]."<br />";
  echo "Email: " .$result [12]."<br />";
  echo "Website: " .$result [13]."<br />";
}
}
?>



Basically I want to know how loop through to show multiple results. So far only 1 record is being returned to my website page even when there is more then one match.
Also how would I go about allowing a user to Select a check box as an input?

One more issue..the registration form that create the table (this table is then searched by the above form) has some issues. I have a problem with saving check box values into my database. On events I have Supported_Consoles[] in the Handle Array section. This corresponds to <input type="checkbox" name="Supported_Consoles[]" id="supported_consoles_1" title="" value="XBOX360 " class="" /> (note that the supported_console_id changes for every checkbox I have.)
For example, if I check PS3 and XBOX360 checkbox it shows the following in the database: PS3 Supported_Games[]XBOX360 . Why would it be showing the 'supported_Games[]' for? Any solution for this!


Thank you! (sorry about the long post🙂
GreyHead 02 Jun, 2012
Hi JakeI,

The easy way to do this is to use the DB Multi-Record Loader and turn on the Data Displayer. This works nice to create a filtered list.

That said, your code looks OK to me and I can't see why it is only outputting a single record. Is the problem with the query or the foreach loop?

The Handle Arrays action probably doesn't like the [], try using just Supported_Games

Bob
This topic is locked and no more replies can be posted.