Forums

A form using jos_users and jos_comprofiler

cobayecrau 06 Feb, 2009
Hello,
With a big help from Bob 😀 , here is the code for a form dealing with a diving log book.
We use three tables jos_users, jos_comprofiler and jos_seminar (Seminar allows to handle events).
It's not the final release I have to add css and to finish what I call the loop (after each submit1, I reload the form until the end and I close with submit2)
Anyway I think it can help

<DIV class=form_item   >
<DIV class="form_element cf_dropdown" ><LABEL class=cf_label >sélectionner un événement</LABEL>
    <?php
    $db =& JFactory::getDBO();
    $query = "
      SELECT id, title
        FROM #__seminar WHERE NOW() > end ";
    $db->setQuery($query);
    $rows = $db->loadObjectList();
    ?>
    
    <SELECT class="cf_inputbox validate-selection" id=select_3 size=3 name=select_3 >
    <?php
    foreach ( $rows as $row )
 {
     echo "<option value='".$row->id."' >".$row->title."</option>";
}
?>
    </select>
   
</DIV>
<DIV class=clear > </DIV></DIV>


<DIV class=form_item   >
<DIV class="form_element cf_dropdown" >
<LABEL class=cf_label >sélectionner un directeur de plongée</LABEL>
<?php
    $db =& JFactory::getDBO();
$query = "
  SELECT * 
    FROM ".$db->nameQuote('#__users')." a
    INNER JOIN ".$db->nameQuote('#__comprofiler')." b
      ON ( a.id = b.id )
    WHERE ( b.cb_niveauencadrement != '' )";

    $db->setQuery($query);
    $rows = $db->loadObjectList();
?>
    
    <SELECT class="cf_inputbox validate-selection" id=select_4 size=3 name=select_4 >
    <?php
    foreach ($rows as $row)
  {
     echo "<option value='".$row->id."' >".$row->name."</option>";
}
   ?>
    </select>
</DIV>
<DIV class=clear > </DIV></DIV>

<DIV class=form_item   >
<DIV class="form_element cf_textbox" >
<LABEL class=cf_label >Palanquée n° :</LABEL>
<INPUT class="cf_inputbox required validate-digits" id=text_5  maxLength=2 size=2 name=text_5 >
<A class=tooltiplink onclick="return false;"  ><IMG class=tooltipimg  height=16 src="components/com_chronocontact/css/images/tooltip.png" width=16 border=0 ></A>
<DIV class=tooltipdiv  >Palanquée n° : :: Numéro d'ordre de la palanquée</DIV>
</DIV>
<DIV class=clear > </DIV></DIV>


<DIV class=form_item   >
<DIV class="form_element cf_dropdown" >
<LABEL class=cf_label >Sélectionner le guide :</LABEL>
<?php
$db =& JFactory::getDBO();
$query = "
  SELECT * 
    FROM ".$db->nameQuote('#__users')." a
    INNER JOIN ".$db->nameQuote('#__comprofiler')." b
      ON ( a.id = b.id )
    WHERE ( b.cb_niveauencadrement != '' )
      OR ( b.cb_niveauplongeur = 'Niveau 4' )";
$db->setQuery($query);
$rows = $db->loadObjectList();
?>
    
    <SELECT class="cf_inputbox validate-selection" id=select_5 size=3 name=select_5 >
    <?php
    foreach ($rows as $row)
{ 
echo "<option value='".$row->id."' >".$row->name."</option>"; 
}
     ?>
    </select>
<A class=tooltiplink onclick="return false;"  ><IMG class=tooltipimg  height=16 src="components/com_chronocontact/css/images/tooltip.png" width=16 border=0 ></A>
<DIV class=tooltipdiv  >Sélectionner le guide : :: Guide ou moniteur</DIV>
</DIV>
<DIV class=clear > </DIV></DIV>

<?php
$db =& JFactory::getDBO();
$query = "
  SELECT id, name
    FROM #__users ";
$db->setQuery($query);
$rows = $db->loadObjectList();
?>
<div class='form_item' >
  <div class="form_element cf_dropdown" >
    <label class='cf_label' >Sélectionner les plongeurs</label>
    <select class="cf_inputbox validate-selection" id='select_6' multiple='multiple' size='4' name=select_6[]  >
<?php
    foreach ( $rows as $row )
 {
     echo "<option value='".$row->id."' >".$row->name."</option>";}
?>
    </select>
    <a class='tooltiplink' onclick="return false;"  >
      <img class='tooltipimg'  height='16' src="components/com_chronocontact/css/images/tooltip.png" width='16' border='0' >
    </a>
    <div class='tooltipdiv' >Sélectionner les plongeurs :: Sélectionner au plus 4 plongeurs utilisez les touches <CTRL><C></div>
  </div>
  <div class='clear' > </div>
</div>


<DIV class=form_item   >
<DIV class="form_element cf_textbox" ><LABEL class=cf_label >Heure de départ</LABEL><INPUT class="cf_inputbox required validate-date" id=text_8  maxLength=10 size=10 name=text_8 ></DIV>
<DIV class=clear > </DIV></DIV>

<DIV class=form_item   >
<DIV class="form_element cf_textbox" ><LABEL class=cf_label >Heure de sortie</LABEL><INPUT class="cf_inputbox validate-date" id=text_9  maxLength=10 size=10 name=text_9 ></DIV>
<DIV class=clear > </DIV></DIV>

<DIV class=form_item   >
<DIV class="form_element cf_textbox" ><LABEL class=cf_label >Palier Ă  3 m :</LABEL><INPUT class="cf_inputbox validate-number" id=text_10  maxLength=150 size=30 name=text_10 ><A class=tooltiplink onclick="return false;"  ><IMG class=tooltipimg  height=16 src="components/com_chronocontact/css/images/tooltip.png" width=16 border=0 ></A>
<DIV class=tooltipdiv  >Palier à 3 m : :: saisir la durée du palier en mn</DIV></DIV>
<DIV class=clear > </DIV></DIV>

<DIV class=form_item   >
<DIV class="form_element cf_textbox" ><LABEL class=cf_label >Palier Ă  6 m :</LABEL><INPUT class="cf_inputbox validate-number" id=text_11  maxLength=150 size=30 name=text_11 ><A class=tooltiplink onclick="return false;"  ><IMG class=tooltipimg  height=16 src="components/com_chronocontact/css/images/tooltip.png" width=16 border=0 ></A>
<DIV class=tooltipdiv  >Palier à 6 m : :: Saisir la durée du palier  à 6 m</DIV></DIV>
<DIV class=clear > </DIV></DIV>

<DIV class=form_item   >
<DIV class="form_element cf_textarea" ><LABEL class=cf_label >Commentaires :</LABEL><TEXTAREA class=cf_inputbox id=text_12 name=text_12 rows=3 cols=30 ></TEXTAREA><A class=tooltiplink onclick="return false;"  ><IMG class=tooltipimg  height=16 src="components/com_chronocontact/css/images/tooltip.png" width=16 border=0 ></A>
<DIV class=tooltipdiv  >Commentaires : :: Saisir ici vos commentaires, objet de la plongée, faits marquants</DIV></DIV>
<DIV class=clear > </DIV></DIV>

<DIV class=form_item   >
<DIV class="form_element cf_button" ><INPUT  type=submit value=Submit1 ></DIV>
<DIV class=clear > </DIV></DIV>

<DIV class=form_item   >
<DIV class="form_element cf_button" ><INPUT  type=submit value=Submit2 ></DIV>
<DIV class=clear > </DIV></DIV>


dasofsky 01 Oct, 2010
Guys,

I am really hoping someone can help me. I have been reading the forums and trying to figure out how to populate a drop down from a database:

The particulars are:

Source:
Database Name: dasofsky_jo151
Table of Data I want to pull from: jos_chronoforms_simple
Field I would like to populate from: st_first_name
Position in table: 6

Table I would like to populate: jos_chronoforms_note_bus
Field of Drop Down: nt_student
Position in table: 9

Here is the code I am trying to use:
<DIV class="form_item"   >
<DIV class="form_element cf_dropdown" >
 <label class="cf_label" style="width: 150px;">Student</label>
    <?php
   $db =& JFactory::getDBO();
    $query = "SELECT st_first_name
        FROM jos_chronoforms_simple;"
    $db->setQuery($query);
    $rows = $db->loadResultArray(9);
    ?>
   
    <SELECT class="cf_inputbox validate-selection" id=select_4 size=1 name=nt_student>
<?php
    foreach ($rows as $row => $current) {
      echo "<option value='$current'>$current</option>";
    }
    ?>
    </select>
  </div>
  <div class="cfclear"> </div>
</div>




I would really, really appreciate any help!!!

Thanks in advance for your help,

DA
GreyHead 01 Oct, 2010
Hi dasofsky,

Try deleting the 9 from this line: $rows = $db->loadResultArray(9);

Otherwise the code looks good from a quick read.

Bob
pokemon 08 Nov, 2010

Guys,

I am really hoping someone can help me. I have been reading the forums and trying to figure out how to populate a drop down from a database:

The particulars are:

Source:
Database Name: dasofsky_jo151
Table of Data I want to pull from: jos_chronoforms_simple
Field I would like to populate from: st_first_name
Position in table: 6

Table I would like to populate: jos_chronoforms_note_bus
Field of Drop Down: nt_student
Position in table: 9

Here is the code I am trying to use:

<DIV class="form_item"   >
<DIV class="form_element cf_dropdown" >
 <label class="cf_label" style="width: 150px;">Student</label>
    <?php
   $db =& JFactory::getDBO();
    $query = "SELECT st_first_name
        FROM jos_chronoforms_simple;"
    $db->setQuery($query);
    $rows = $db->loadResultArray(9);
    ?>
   
    <SELECT class="cf_inputbox validate-selection" id=select_4 size=1 name=nt_student>
<?php
    foreach ($rows as $row => $current) {
      echo "<option value='$current'>$current</option>";
    }
    ?>
    </select>
  </div>
  <div class="cfclear"> </div>
</div>




I would really, really appreciate any help!!!

Thanks in advance for your help,

DA




If you still have a problem with this code, change this:
$query = "SELECT st_first_name
FROM jos_chronoforms_simple;"
into this
$query = "SELECT st_first_name
FROM jos_chronoforms_simple"; (switch the " and ; )
pokemon 13 Nov, 2010
The code works for viewing the fields, but they don't get saved. If I make a database from scratch with the form as bases, it doesn't take this field automatically.
pokemon 03 Dec, 2010
I can't find a solution, can someone help?
GreyHead 03 Dec, 2010
Hi pokemon,

Which field doesn't get saved - nt_student?

Do you have an nt_student column in the table?

Bob
pokemon 03 Dec, 2010
If I create a new database, using my form, the wizard doesn't recognize the field to create the field automatically.
GreyHead 03 Dec, 2010
Hi pokemon,

I'm sorry, I don't know what that means. The Wizard never recognises new columns in a database table.

Bob
pokemon 07 Dec, 2010
I try to make a new table based on the form (containing a dropdownbox). The wizard for creating a new table normally suggests all fields of the form but in this case it doesn't suggest to make a field for the contents of the dropdownbox.
How can I save the contents of this dropdownbox to a field in my table?
GreyHead 07 Dec, 2010
Hi pokemon,

The wizard will usually recognise any from input with a name attribute.

You can always add a column using PHPMyAdmin, but you must then refresh the DB Connection.

Bob
pokemon 27 Dec, 2010
When i changed this code
<SELECT class="cf_inputbox validate-selection" id=select_3 size=3 name=select_3 >


into
<SELECT class="cf_inputbox validate-selection" id="select_3" size="3" name="select_3" >

the field is recognized in the autogenerate page.

Adding a column using PhpMyadmin and refreshing DB connection doesn't work with my form, I have no idea why.

Anyway, I found a solution, thanks for your help.
GreyHead 27 Dec, 2010
Hi pokemon,

Good catch! I missed the missing quotes. It's good practice to quote all attribute values. The ChronoForms parse is fairly good in finding the name attributes but I suspect that the name=select_4> shown earlier in this thread will defeat it.

Bob
Phatboy 18 Aug, 2011
I did a lot of searching and could not find anything on this. A couple of questions



There are some fields that are not updating, for instance email. When a user registers, there is a record created for both jos_comprofiler and jos_users. Everything appears to be updating except jos_comprofiler.cb_mail. Even when I sync.

On the registration form everything is CB (it appears) except the First Name, Last Name, Username, and Password. It appears that everything is updating between the two tables, except email. Because jos_users.email is a part of the registration form of course, it is there. However, it is not in the jos_comprofiler table.

Is it possible I have something configured incorrectly?

Has anyone written an SQL statement updating the fields in jos_comprofiler from the jos_users table?


Thanks.
GreyHead 18 Aug, 2011
Hi Phatboy,

I'm not a CB user and don't have any immediate explanation :-(

Which version of ChronoForms are you using? You can find the version from Site Admin | Extensions | Install/Uninstall | Components in Joomla! 1.5 or Site Admin | Extensions | Extension Manager | Manage in Joomla! 1.6.

I think that someone posted some CFv4 code for CB here in the last couple of weeks. That might help.

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