mysql database query in element (select from list)

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

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

$this->execPieceByName('ff_InitLib'); //Include BreezingForms Library
$db = JFactory::getDBO();//Get Database Object

//Create your own query here
$db->setQuery('SELECT * from vagas');

$result = $db->loadColumn(); //load the result from the query
$test = "0;Choose option; \n";
for ($i = 0; $i < count($result); $i++)
{
$test .= "0;".$result[$i].";".$result[$i]."\n";
}

function ff_setSelectList($name, $value)
{
global $ff_processor;
for ($r = 0; $r < $ff_processor->rowcount; $r++)
{
$row =& $ff_processor->rows[$r];
if ($row->name==$name)
$row->data2 = $value;
unset($row);
} // for
} // ff_setSelectList

ff_setSelectList('vagas_escola', $test);

This is the code I'm using and it works out in part.

Now you see the result for the selection field but it is not bringing the columns that I need.

The columns are: id, serie, descricao_vaga e quantidade_de_vaga.
I tried this way

$test .= "0;". $result[id]. $result[serie].$result[descricao_vaga] ";" $result[$id]. "\ n";

But it did not work..

here is the address where it is working -> www.sistemas.ti.educacaoluziania.go.gov.br/

can you help me?
#231749
  • Posts: 1437
  • Karma: 48
  • Thank you received: 188

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

Hello again,

So you would like to display in select list options all of the following data: id, serie, descricao_vaga and quantidade_de_vaga, is that correct?

Or you would like it to look like this: "Dom Bosco - 20 Vagas"? If that is the case, from which calumns is this data?

Please explain what exactly you want to have shown in select list. In my opinion it is too much to show all of the following: id, serie, descricao_vaga and quantidade_de_vaga.

Regards,

Mihaela
#231766
  • mlangamer
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 23
  • Thank you received: 0

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

I need to make a selection in mysql with the result of a selct list. How do I do this?
Where do I put the code? What's your name? An example, please.
#231993
  • Posts: 1437
  • Karma: 48
  • Thank you received: 188

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

Hello again,

Based on what you previously wanted, this might be the solution to your problem crosstec.org/en/forums/1-forums/104294-p...rom-sql.html?start=0 . To send all the data in select list and split them to other fields based on what was selected.

If you don't want to use that solution, you can query the database depending on what was selected in select list element using AJAX. It requires some custom coding.

Here you can take a look at an example how to do so crosstec.org/en/forums/37-contentbuilder...database.html#214031
Here you can take a loo at more examples crosstec.org/en/forums/1-forums/125324-b...to-mysql.html#231658 and
crosstec.org/en/forums/35-form-help/1006...ect-list.html#122145 .

In this example crosstec.org/en/forums/1-forums/115058-i...-tables.html?start=6 you can see a package with an example form that will fills fields name, lastname, city etc. from database based on client_id entered in the form.

Regards,

Mihaela
#232026
  • mlangamer
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 23
  • Thank you received: 0

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

Thank you very much for your attention!

I have prepared this code but it is not working.


File: selecao01.php

<?php
if(!isset($_SERVER)){
// redirect them to your desired location
header('../index.php');
exit;
}
I put the right information here
define("HOSTNAME","*");
define("USERNAME","*");
define("PASSWORD","*");
define("DATABASE","*");

//where id=".$id and serie="Educação Infantil I"

$dbhandle=new mysqli(HOSTNAME,USERNAME,PASSWORD,DATABASE) or die("Unable to Connect DB");
header("Content-Type: application/json");

$tipo_vaga = $_GET;

$query="select escola, serie, quantidade_de_vagas from vagas where serie =".$tipo_vaga ;

$data = array();
$rs=$dbhandle->query($query);

while ($row = $rs->fetch_array()) {
$data[] = $row;
}
echo json_encode($data);
?>


Source ajax :

jQuery.ajax({
type: 'GET',
url: './selecao01.php',
data: 'id=' + jQuery(vagas_disponiveis).val() ,
success: function(data){
jQuery("vagas_escola").val(data[0].escola);
}
});

my wish and make a selection of schools with vacancies available from the first selection.

the address is here www.sistemas.ti.educacaoluziania.go.gov.br/

has an image to illustrate better att
#232062
Attachments:
  • mlangamer
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 23
  • Thank you received: 0

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

Can someone help me?
#232152
Moderators: ForumSupporttomeperica
Time to create page: 0.204 seconds

New Support System

Dear Customers,

Users with active subscription have support priority which will be dona via ServiceDesk (My Account > Raise a ticket).
FREE Support topics will be answered when AND if there is time.

You can check support guidelines here : here

Regards,
Crosstec Team

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

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€

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