mysql database query in element (select from list)

  • mlangamer
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 24
  • Thank you received: 0

mlangamer replied the topic: mysql database query in element (select from list)

Yes! how do I do that?
#232418
  • mlangamer
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 24
  • Thank you received: 0

mlangamer replied the topic: mysql database query in element (select from list)

did not work
#232419
Attachments:
  • mlangamer
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 24
  • Thank you received: 0

mlangamer replied the topic: mysql database query in element (select from list)

Disregard my last message because everything worked out as you did. Now I need to know how to fill in the vacant and e-mail fields depending on which school was selected in the other selection list. Thank you very much my darling . God bless you a lot and a lot
#232423
  • Posts: 2348
  • Karma: 85
  • Thank you received: 315

mihaela replied the topic: mysql database query in element (select from list)

Hello again,

Thank you for the kind words. :)
I'm here to help.

I'm glad that the previous solution did work for you in the end.

To fill in the vacant and e-mail fields depending on which school was selected in the other selection list follow these steps:

1) Go to Advanced properties of second select list "vagas_escola" and in Actionscript section set Type to Custom and check the Change checkbox.
Then in the code area below put the following code:
function ff_vagas_escola_action(element, action)
{
   switch (action) {
        case 'change':
            jQuery.ajax({
                type: "POST",
                url: "http://localhost/value2.php",
                data: { vagas_escola: element.value },    
                success: function(data) {
                var obj = JSON.parse(data);
                var arr = obj;
                ff_getElementByName('vaga').value = arr[0];
                ff_getElementByName('emailescola').value = arr[1];
                
                }      
            });
            break;
        default:;
    } // switch
} // ff_vagas_escola_action
This will make another ajax call to database.
This will fill textfields named "vaga" and "emailescola" with the vacant and e-mail retrieved from database.

NOTE: Replace "http://localhost/value2.php" with the correct url to the new value.php2 file that you will create.

2) Then go to the Joomla root folder and create there file named value2.php with the following content:
<?php

define('_JEXEC', 1);
if (file_exists(__DIR__ . '/defines.php'))
{
	include_once __DIR__ . '/defines.php';
}
if (!defined('_JDEFINES'))
{
	define('JPATH_BASE', __DIR__);
	require_once JPATH_BASE . '/includes/defines.php';
}
require_once JPATH_BASE . '/includes/framework.php';


$judgePick = JRequest::getVar('vagas_escola'); 
$db = JFactory::getDBO();
$db->setQuery('SELECT `quantidade_de_vagas`, `email_escola` FROM `vagas` WHERE escola ='.$db->quote($judgePick)); 
$result = $db->loadRow();
 if(!$result){
 	echo "error";
} else {
	echo json_encode($result);
}
NOTE: `quantidade_de_vagas` and `email_escola` must correspond to the names of the columns in the table vagas in order for this to work.

Let me know whether you've managed to apply this to your form and whether it works as you wanted.

Regards,

Mihaela
#232442
  • mlangamer
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 24
  • Thank you received: 0

mlangamer replied the topic: mysql database query in element (select from list)

Hello Mihaela
Everything worked. Just as you walked it was done and everything went right. It worked!
I'd like to of course without abusing your goodwill, but rather leverage to learn more about how to use this tool.

Now I need to make two more adjustments to the form.

• First, do not let the same student enroll in two schools. If he is already registered in a school send a message saying that the student is already registered in the network. The Key Fields are: (nome) and (telefone).

• Secondly perform a calculation on the Element (Nascimento), because this field is the date of birth of the student and depending on the date he was born already set the Element (tipo_vaga)

Example:
If the student's date of birth, Element (Nascimento) is greater than one year and six months set the Element (tipo_vaga) as (Educação Infantil – creche IA) and from there will already show vacancies for this series only.
If you can guide me I thank you very much.
#232492
  • mlangamer
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 24
  • Thank you received: 0

mlangamer replied the topic: mysql database query in element (select from list)

One more detail would like to send an email to the school through the element (emailescola). I already tried to put it in Admin Emails / Email to / {emailescola: value} but it is not working. If you can guide me where as how to proceed.
God bless you!
#232493
Moderators: ForumSupporttomeperica
Time to create page: 0.101 seconds

Summer Sale!

50% discount on all of our extension subscription plans & templates!

Get Your Subscription Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99 for just 49! (Summer Sale)

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here