Forums

RE: Need Assistance with Search Form..PLEASE

about2flip 20 May, 2011
I've created this search form, and I am a Newbie with Mysql. I want to display the return results from the query of this form. Can anyone help me. I can't figure out how to do it.

<div class="form_item">
  <div class="form_element cf_heading">
    <h1 class="cf_text">Search Flowers</h1>
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 400px;">Event Type:</label>
    <select class="cf_inputbox" id="select_1" size="1" title=""  name="event_type">
    <option value="">Choose Event</option>
      <option value="Anniversary Party">Anniversary Party</option>
<option value="Baby Shower">Baby Shower</option>
<option value="Bachelor Party">Bachelor Party</option>
<option value="Bar Mitzvah">Bar Mitzvah</option>
<option value="Bat Mitzvah">Bat Mitzvah</option>
<option value="Birthday Party">Birthday Party</option>
<option value="Bridal Shower">Bridal Shower</option>
<option value="Christening">Christening</option>
<option value="Communion">Communion</option>
<option value="Corporate Event">Corporate Event</option>
<option value="Dinner Party">Dinner Party</option>
<option value="Engagement Party">Engagement Party</option>
<option value="Family Event">Family Event</option>

    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 400px;">State: (Flowers available in the states listed)</label>
    <select class="cf_inputbox" id="state" size="1" title=""  name="state">
    <?php
if (!$mainframe->isSite() ) {return;}
$db =& JFactory::getDBO();
$query = "
SELECT `state`
FROM #__chronoforms_listflowers_2 
"; 
$db->setQuery($query);
$options = $db->loadAssocList();
foreach ( $options as $o ) {
	echo "<option value='".$o['cf_id']."'>".$o['state']."</option>";
}
?>

</select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_text"> <span class="cf_text">Price Range (per centerpiece)</span> </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 400px;"></label>
    <select class="cf_inputbox" id="price_range" size="1" title=""  name="price_range">
    <option value="">Choose Range</option>
      <option value="$0 to $10">$0 to $10</option>
<option value="$10 to $30">$10 to $30</option>
<option value="$30 to $50">$30 to $50</option>
<option value="$50 to $100">$50 to $100</option>
<option value="$100 to $160">$100 to $160</option>

    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_text"> <span class="cf_text">Pick Up Date</span> </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_datetimepicker">
    <label class="cf_label" style="width: 400px;">From:</label>
    <input class="cf_datetime" title="" size="20" id="pickup_date" name="pickup_date" type="text" />
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_datetimepicker">
    <label class="cf_label" style="width: 400px;">To:</label>
    <input class="cf_datetime" title="" size="20" id="pickup_date2" name="pickup_date2" type="text" />
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_button">
    <input value="Search" name="button_11" type="submit" />
  </div>
  <div class="cfclear"> </div>
</div>




So I want to use this code to display my searches
 $data = JRequest::get('post');
// Check which search fields have been submitted and add to the Where clause
$cond = array();
if ($data['event_type']) {
    $cond[] = 'event_type='.$this->_db->Quote($data['event_type']);
}
if ($data['zipcode']) {
    $cond[] = 'zipcode='.$this->_db->Quote($data['zipcode']);
}
if ($data['price_range']) {
    $cond[] = 'price_range='.$this->_db->Quote($data['price_range']);
}
if ($data['pickup_from']) {
    $cond[] = 'pickup_from >= '.$this->_db->Quote($data['pickup_from']);
}
if ($data['pickup_to']) {
    $cond[] = 'pickup_to <= '.$this->_db->Quote($data['pickup_to']);
}
if (count($cond) > 0) {
    $where = ' WHERE ' . implode(' AND ', $cond);
}

$query = 'SELECT * FROM listflowers_2 ' . $where;
$this->_db->setQuery($query);
$results = $this->_db->loadObjectList(); 
GreyHead 21 May, 2011
Hi about2flip,

I think that I've said before that this looks like a ChronoConnectivity application. It takes more work to get it done in ChronoForms ut is possible.

Your Where clause code looks like it belongs in a Class but the Class code isn't there. Does this code actually work? i.e. does $results have any contents?

If it does then you'd display the results by building a table and putting each set of results into a table row using
foreach ( $results as $row ) { 
. . .

Bob
about2flip 22 May, 2011
Can't get this to submit. When I hit the submit button it is not getting data. I have been on this for 5 days, and I read through all the tutorials...What I am I doing wrong??? I see others getting help on this forum, but when I ask for help I cant get anything. PLEASE, PLEASE HELP. THanks

This is my Where
<?php
$event = JRequest::getString('event_type', '', 'post');
$where = array();
if ( $event ) {
  $where[] = " `occassion_type` LIKE '%$event%' ";
}
?>


This is my Header. I know I only have one event listed in my where, but I wanted to test to make sure I am doing this right. I can't not get any results from the DB, and YES I do I have the correct DB selected in the General Settings
<div class="form_item">
  <div class="form_element cf_heading">
    <h1 class="cf_text">Search Flowers</h1>
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 400px;">Event Type:</label>
    <select class="cf_inputbox" id="event_type" size="1" title=""  name="event_type" value=''/>
    <option value="">Choose Event</option>
      <option value="Anniversary Party">Anniversary Party</option>
<option value="Baby Shower">Baby Shower</option>
<option value="Bachelor Party">Bachelor Party</option>
<option value="Bar Mitzvah">Bar Mitzvah</option>
<option value="Bat Mitzvah">Bat Mitzvah</option>
<option value="Birthday Party">Birthday Party</option>
<option value="Bridal Shower">Bridal Shower</option>
<option value="Christening">Christening</option>
<option value="Communion">Communion</option>
<option value="Corporate Event">Corporate Event</option>
<option value="Dinner Party">Dinner Party</option>
<option value="Engagement Party">Engagement Party</option>
<option value="Family Event">Family Event</option>

    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 400px;">State: (Flowers available in the states listed)</label>
    <select class="cf_inputbox" id="state" size="1" title=""  name="state">
    <?php
$db =& JFactory::getDBO();
$query = "
SELECT `state`
FROM #__chronoforms_listflowers_2 
"; 
$db->setQuery($query);
$options = $db->loadAssocList();
foreach ( $options as $o ) {
	echo "<option value='".$o['cf_id']."'>".$o['state']."</option>";
}
?>

</select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_text"> <span class="cf_text">Price Range (per centerpiece)</span> </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 400px;"></label>
    <select class="cf_inputbox" id="price_range" size="1" title=""  name="price_range">
    <option value="">Choose Range</option>
      <option value="$0 to $10">$0 to $10</option>
<option value="$10 to $30">$10 to $30</option>
<option value="$30 to $50">$30 to $50</option>
<option value="$50 to $100">$50 to $100</option>
<option value="$100 to $160">$100 to $160</option>

    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_text"> <span class="cf_text">Pick Up Date</span> </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_datetimepicker">
    <label class="cf_label" style="width: 400px;">From:</label>
    <input class="cf_datetime" title="" size="20" id="pickup_date" name="pickup_date" type="text" />
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_datetimepicker">
    <label class="cf_label" style="width: 400px;">To:</label>
    <input class="cf_datetime" title="" size="20" id="pickup_date2" name="pickup_date2" type="text" />
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_button">
    <input type='submit'
name='Search' id='search' value='submit' />
  </div>
  <div class="cfclear"> </div>
</div>
<table>


Then I have a table row in my body. Thanks
GreyHead 23 May, 2011
Hi about2flip,

You've missed this part from the code in my earlier post:
if (count($cond) > 0) {
    $where = ' WHERE ' . implode(' AND ', $cond);
}
echo $where;

Though in fact you don't need that if you only have one 'where clause'.
<?php
$event = JRequest::getString('event_type', '', 'post');
if ( $event ) {
  echo = " WHERE `occassion_type` LIKE '%$event%' ";
}
?>

Bob
about2flip 26 May, 2011
I spent the last two weeks going through this forum, reading through my Chronoforms 3.1 book, and for the love of me, I CAN NOT get the records returned. I need the user to choose from two dropdown menus, and just return the data.

PLEASE BOB CAN YOU HELP

<div class="form_item">
  <div class="form_element cf_heading">
    <h1 class="cf_text">Search Flowers</h1>
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 400px;">Event Type:</label>
    <select class="cf_inputbox" id="event_type" size="1" title=""  name="event_type">
    <option value="">Choose Event</option>
      <option value="Anniversary Party">Anniversary Party</option>
<option value="Baby Shower">Baby Shower</option>
<option value="Bachelor Party">Bachelor Party</option>
<option value="Bar Mitzvah">Bar Mitzvah</option>
<option value="Bat Mitzvah">Bat Mitzvah</option>
<option value="Birthday Party">Birthday Party</option>
<option value="Bridal Shower">Bridal Shower</option>
<option value="Christening">Christening</option>
<option value="Communion">Communion</option>
<option value="Corporate Event">Corporate Event</option>
<option value="Dinner Party">Dinner Party</option>
<option value="Engagement Party">Engagement Party</option>
<option value="Family Event">Family Event</option>

    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 400px;">State: (Flowers available in the states listed)</label>
    <select class="cf_inputbox" id="state" size="1" title=""  name="state">
    <?php
$db =& JFactory::getDBO();
$query = "
SELECT `state`
FROM #__chronoforms_listflowers_2 
"; 
$db->setQuery($query);
$options = $db->loadAssocList();
foreach ( $options as $o ) {
	echo "<option value='".$o['cf_id']."'>".$o['state']."</option>";
}
?>

</select>
    
  </div>
  <div class="cfclear"> </div>
</div>

    
  <div class="form_item">
  <div class="form_element cf_button">
    <input value="Search" name="button_11" type="submit" />
  </div>
  <div class="cfclear"> </div>
</div>



GreyHead 26 May, 2011
Hi about2flip,

Code in the OnSubmit fter box id just displayed; you can put form code there but it won't be submitted or processed by ChronoForms.

If you want the user to complete a new form then ReDirect them to a new form.

Bob

PS Your previous posts here appeard to be about ChronoConnectivity? Is there any Connection between the two? I have long ago given up trying to understand what you are trying to do and where. If you could explain that clearly it would be easier to help.
about2flip 26 May, 2011
I am using this code in the form HTML section
<div class="form_item">
  <div class="form_element cf_heading">
    <h1 class="cf_text">Search Flowers</h1>
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 400px;">Event Type:</label>
    <select class="cf_inputbox" id="select_1" size="1" title=""  name="event_type">
    <option value="">Choose Event</option>
      <option value="Anniversary Party">Anniversary Party</option>
<option value="Baby Shower">Baby Shower</option>
<option value="Bachelor Party">Bachelor Party</option>
<option value="Bar Mitzvah">Bar Mitzvah</option>
<option value="Bat Mitzvah">Bat Mitzvah</option>
<option value="Birthday Party">Birthday Party</option>
<option value="Bridal Shower">Bridal Shower</option>
<option value="Christening">Christening</option>
<option value="Communion">Communion</option>
<option value="Corporate Event">Corporate Event</option>
<option value="Dinner Party">Dinner Party</option>
<option value="Engagement Party">Engagement Party</option>
<option value="Family Event">Family Event</option>

    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 400px;">State: (Flowers available in the states listed)</label>
    <select class="cf_inputbox" id="state" size="1" title=""  name="state">
    <?php
if (!$mainframe->isSite() ) {return;}
$db =& JFactory::getDBO();
$query = "
SELECT `state`
FROM #__chronoforms_listflowers_2 
"; 
$db->setQuery($query);
$options = $db->loadAssocList();
foreach ( $options as $o ) {
   echo "<option value='".$o['cf_id']."'>".$o['state']."</option>";
}
?>

</select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_text"> <span class="cf_text">Price Range (per centerpiece)</span> </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 400px;"></label>
    <select class="cf_inputbox" id="price_range" size="1" title=""  name="price_range">
    <option value="">Choose Range</option>
      <option value="$0 to $10">$0 to $10</option>
<option value="$10 to $30">$10 to $30</option>
<option value="$30 to $50">$30 to $50</option>
<option value="$50 to $100">$50 to $100</option>
<option value="$100 to $160">$100 to $160</option>

    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_text"> <span class="cf_text">Pick Up Date</span> </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_datetimepicker">
    <label class="cf_label" style="width: 400px;">From:</label>
    <input class="cf_datetime" title="" size="20" id="pickup_date" name="pickup_date" type="text" />
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_datetimepicker">
    <label class="cf_label" style="width: 400px;">To:</label>
    <input class="cf_datetime" title="" size="20" id="pickup_date2" name="pickup_date2" type="text" />
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_button">
    <input value="Search" name="button_11" type="submit" />
  </div>
  <div class="cfclear"> </div>
</div>


I have been putting different code in the submit after email section that will help me to display data based on what the user selects from the drop-down boxes. From previous post I have tried different things. I have tried Chrono-connectivity, and can't get nothing to display either.

I had this in the WHERE of CC and it returns nothing.
<?php
$event = JRequest::getString('event_type', '', 'post');
if ( $event ) {
  echo = " WHERE `occassion_type` LIKE '%$event%' ";
}
?>
about2flip 27 May, 2011
Wow, Bob really gave up. Two weeks on this, and still I have not figured out how to return my selections from my drop downs. Anyone else can help PLEASE? Sorry for my lack of experience with chronoforms/chronoconnectivity.
GreyHead 28 May, 2011
Hi about2flip,

This still looks to me like a ChronoConnectivity application. Have you looked at the tutorials here

Bob
about2flip 28 May, 2011
Yes, downloaded all tutorials, even purchased one. All I'm trying to do is show the results from the drop-down to the user in a table. Like I stated I have this in my html

 <div class="form_item">
  <div class="form_element cf_heading">
    <h1 class="cf_text">Search Flowers</h1>
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 400px;">Event Type:</label>
    <select class="cf_inputbox" id="event_type" size="1" title=""  name="event_type">
    <option value="">Choose Event</option>
      <option value="Anniversary Party">Anniversary Party</option>
<option value="Baby Shower">Baby Shower</option>
<option value="Bachelor Party">Bachelor Party</option>
<option value="Bar Mitzvah">Bar Mitzvah</option>
<option value="Bat Mitzvah">Bat Mitzvah</option>
<option value="Birthday Party">Birthday Party</option>
<option value="Bridal Shower">Bridal Shower</option>
<option value="Christening">Christening</option>
<option value="Communion">Communion</option>
<option value="Corporate Event">Corporate Event</option>
<option value="Dinner Party">Dinner Party</option>
<option value="Engagement Party">Engagement Party</option>
<option value="Family Event">Family Event</option>

    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 400px;">State: (Flowers available in the states listed)</label>
    <select class="cf_inputbox" id="state" size="1" title=""  name="state">
<option value="">Choose State</option>
    <?php
$db =& JFactory::getDBO();
$query = "
SELECT `state`
FROM #__chronoforms_listflowers_2 
"; 
$db->setQuery($query);
$options = $db->loadAssocList();
foreach ( $options as $o ) {
	echo "<option value='".$o['cf_id']."'>".$o['state']."</option>";
}
?>

</select>
    
  </div>
  <div class="cfclear"> </div>
</div>

    
  <div class="form_item">
  <div class="form_element cf_button">
    <input value="Search" name="button_11" type="submit" />
  </div>
  <div class="cfclear"> </div>
</div>


I tried to use so many query's to return my results in chronoconnectivity that I just can't get it.

<?php
$term = $_POST['event_type'];
$sql = mysql_query("select * from #_chronoforms_listflowers_2 where occassion_type like '%$term%'");
while ($row = mysql_fetch_array($sql)){
	echo '<br/> Event Type: '.$row['occassion_type'];
	echo '<br/> State: '.$row['state'];
	echo '<br/><br/>';
	}

?>

This code is giving me an error
This topic is locked and no more replies can be posted.