PHP/ Dropdown list selector

Solved
tsig00 Posted messages 20 Registration date   Status Membre Last intervention   -  
 tsig00 -
Hello,

I am currently doing an internship in IG, and I am working on creating an interface that displays my query in a table (which I managed to do), but the downside is that I learned to create a PHP page (which executes the script) and an HTML page (which displays the result). Unfortunately, we are working on a SQL database and TBS (TinyButStrong) doesn’t work... (I need to download a driver or something and I don’t feel up to doing it at my company... so no touch^^)

So my first question is: can we do dynamic display, meaning can I show my variables from my SQL queries in my PHP page in another HTML page? (without TBS)... if yes, how?

Otherwise, I put everything in the same page and I have my table.

My second objective (this one is a priority) is to insert a dropdown list in the title bar of my table, to display a selector to choose which fields to show in my table (I've been working on this for two days and I'm having trouble).

I created a dropdown list but I am hardcoding the fields... how can I make the different choices in this list correspond to the different fields selected by the selector... and how can I display the choices from the dropdown list as variables...

I thought about making a query for each title case... but I can't manage to integrate PHP into the table... should I do it in a while loop to output:
"select distinct 'relevant fields' from 'relevant table' ".

I browse the forums but I'm not skilled enough to decipher all the information that doesn't necessarily relate to my project.

So any help would be appreciated.

Best regards.

15 réponses

Mihawk Posted messages 4753 Status Contributeur 846
 
Hello,

First, it's important to understand that TBS is a template engine based on PHP global variables.

Translation: whereas generally you insert PHP variables into HTML using the PHP method "echo", with TBS you need to make your PHP variable global and then call it with TBS...

I'm not sure if I'm being clear.
Basically:

<div><?php echo($monPrenom);?></div>


Will become:

<?php global $gMonPrenom = $monPrenom; ?> <div>[onload;var.gMonPrenom]</div>

--
Mihawk
"Rigor makes quality"
1
tsig00 Posted messages 20 Registration date   Status Membre Last intervention  
 
ok ... I admit that it's still quite unclear for me^^
otherwise I tried your code.. it doesn't work on my end... but I managed to put the result of my table into a $_GLOBALS variable, here's where I stand:

//database connection
//connection test
//query
//query execution
//define each cell of the table as a variable

//test global function
function globale()
{
$GLOBALS['table']=$GLOBALS['var1']+$GLOBALS['var2'];
}

//prints the raw table
echo '<pre>';
print_r($table);
echo '</pre>';

//close connection

So I manage to put everything into the $table variable in an array, but I can't retrieve it on another page.... I don't know if I should put it in session super globals or cookies... I thought that $GLOBALS was precisely a superglobal :) allowing me to retrieve my variables on all my pages.. but I don't know how to do that.

Otherwise, I managed to combine everything on one page but I still can't insert a selector into my dropdown list... let me explain:

So I need to make a table that refreshes every 10 seconds or so and corresponds to the result of a query. I'm asked to create a dropdown list (which has the advantage of taking up little space), where you can select multiple options (selector) to sort by type.. the options will correspond to the fields answering the main query.

So I manage to make a dropdown list and display the options based on the query:
ex: 'select distinct nom_oiseau from T_foret' (I'm already happy about that^^)
but adding a selector to it is proving quite difficult for me... so if anyone has an idea I would be glad to test it for them^^ ... someone told me that everything was possible in php^^
0
Mihawk Posted messages 4753 Status Contributeur 846
 
Hi!

So indeed, to pass your array between pages, globals won't be of any use. Globals are accessible to all scripts in use; once the PHP code is executed, they disappear. So, as you rightly said, you need to use sessions!

<?php session_start(); $_SESSION['myArray'] = $GLOBALS['table']; ?>

As for the dropdown lists, you're on the right track! Let's assume your select distinct query works and returns an array containing the bird names. Then in your code, you would have something like:

<select> <?php for ($i=0; $i<count($myBirds); $i++){ echo ('<option value="'.$myBirds[$i]['birdName'].'">'.$myBirds[$i]['birdName'].'</option>'); } ?> </select>

--
Mihawk
"Diligence brings quality"
0
tsig00 Posted messages 20 Registration date   Status Membre Last intervention  
 
ok, for the session start I'm having trouble... I mark it at the top of the page where I initialize the variable, right? after several attempts I've realized that my variable
$GLOBALS['table']=$GLOBALS[var1]+$GLOBALS[var2];
was far from infallible.. so I put the result of my query in a variable
$table[$i]= array ( var1, var2,..);


So at the top of this page, I put:
 <?php session_start(); $_SESSION['monTableau'] = $table; ?> 


But I don't know how to retrieve the variable on another page... I'm not very good at this^^
Do I also need to do a session_start on the page where I want to retrieve this variable? How can I retrieve it?
 echo $monTableau;
?
Anyway, not glorious^^

As for the dropdown list, I did it differently:

 <td class="contour_cellule">Oiseaux <select name=liste size=1 style=font-size: 8 pt> <option selected value=''>Oiseaux</option> <?php while(odbc_fetch_row($requete)) { $Ooiseau=odbc_result($requete,1); ?> <option value=<?php $Ooiseau; ?>><?php echo $Ooiseau; ?></option> <?php } ?></td> 


But how do I add a checkbox to these options?... I'm starting to worry^^
I've tried several solutions with no great success... I'm here but it's just makeshift:
 <code> <td class="contour_cellule">Oiseaux <select name=liste size=1 style=font-size: 8 pt> <option selected value=''>Oiseaux</option> <?php while(odbc_fetch_row($requete)) { $Ooiseau=odbc_result($requete,1); ?> <option value=<?php $Ooiseau; ?><input type="checkbox" name="$Ooiseau" id="$Ooiseau" /> <label for="$Ooiseau">><?php echo $Ooiseau; ?></label></option> <?php } ?></td> 
</code>

..But no need to tell you that this code doesn't work... darn!
0
Mihawk Posted messages 4753 Status Contributeur 846
 
Well then.

First, the issue of sessions.
If you define:

<?php session_start(); $_SESSION['monTableau'] = $table; ?> 

Then on all other pages you can do:

<?php session_start(); $monTableauRecupere = $_SESSION['monTableau']; ?> 

As for your drop-down lists, I would especially like you to explain what you mean by a "selector"?!

--
Mihawk
"Rigor ensures quality"
0
tsig00 Posted messages 20 Registration date   Status Membre Last intervention  
 
Sure! Sorry for the silence, I'm on the weekend starting Friday at noon (yep, some people are lucky^^)...

So I tried it at home and it works very well, just took some time to understand that you need to initialize the session variable in the start... but you have to execute the page that edits the variable before you can use it (I'll see if an include can work for that).

As for the selector: they are checkboxes... for example, we can choose from the different birds available in our dropdown list, and there is a box in front of each of them, we check the boxes corresponding to the birds we want to see in the table: I'd like to be able to use the dropdown principle but select multiple choices from that list... and have the same ergonomics as the dropdown (which doesn’t take up much space when it’s not in use).
0
tsig00 Posted messages 20 Registration date   Status Membre Last intervention  
 
...the weekend was brief... but intense^^

I have another issue...(two actually:mrgreen: :)
I've created my table with a dropdown list and I managed to display a dynamic list based on my query, but my problem is displaying my table based on the selection from my dropdown list... two problems are blocking my way...

1) when I initialize my dropdown list, it defaults to the last selections from 'select distinct nom_oiseau from oiseau' even though I have set the default to bird with value=''...:roll:

 $execution_requete="select distinct nom_oiseau from T_Oiseaux"; ... <select name=liste size=1 style=font-size: 8 pt> <option selected value=''>Bird</option> <?php while(odbc_fetch_row($execution_requete)) { $OOiseau=odbc_result($rexecution_requete,1); ?> <option value=echo $OOiseau;><?php echo $OOiseau; ?></option> <?php } ?></td> 


In the dropdown list, I have all the available birds (from the select distinct), I have correctly marked 'Bird' as default, but the table only shows the rows of my last bird in the list... I think it takes the last value from the while... but that's not at all what I want... if anyone has a solution to suggest, that would be cool^^.

2) My second issue is that when I change the values in my list, the table should regenerate based on the new value... but I should find that on the forum...
0
tsig00
 
Well, the number of responses isn't great ????... but I've made good progress anyway ^^

So I managed to set up an update script in JavaScript, and I hardcoded my dropdown values.
But I'm facing another problem; here's where I am so far (...hang on:)) :

- an HTML page:

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=windows-1250"> <meta name="generator" content="PSPad editor, www.pspad.com"> <link href="../style2.css" rel="stylesheet" type="text/css"> <title></title> <script type="text/javascript"> function MAJ(str) { var ajax; ajax=new XMLHttpRequest(); ajax.onreadystatechange=function() { if (ajax.readyState==4 && ajax.status==200) { document.getElementById("txtHint").innerHTML=ajax.responseText; } } ajax.open("GET","oiseau.php?q="+str,true); ajax.send(); } </script> </head> <body> <form action=""> <div id="txtHint">Les oiseaux seront affichés ici...</div> <table class="contour"> <tr class="titre"> <td class="contour_cellule">age</td> <td class="contour_cellule">repas</td> <td class="contour_cellule"><select name="categorie" onchange="MAJ(this.value);"> <option value="">Selectionnes une categorie:</option> <option value="gros">Gros</option> <option value="moyen">Moyen</option> <option value="petit">Petit</option> </select></td> <td class="contour_cellule">Couleur</td> <td class="contour_cellule">Nbre_Oeuf</td> <td class="contour_cellule">Nom_Oiseau</td> </tr> </table> </form> </body> </html> 


and a PHP page:

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=windows-1250"> <meta name="generator" content="PSPad editor, www.pspad.com"> <link href="../style2.css" rel="stylesheet" type="text/css"> <title></title> <?php $q=$_GET["q"]; //database connection $conn=odbc_connect('','',''); //connection test if ($conn==false) {die("Connection failed");} //query based on the dropdown choice $sql="SELECT * FROM T_Oiseau WHERE taille = '$q'"; //execute the query $rs=odbc_exec($conn,$sql); $i = 0 ; ?> <table class="contour"> <!-- Header row of the table --> <?php //loop through the DB to retrieve all rows while(odbc_fetch_row($rs)) { $repas=odbc_result($rs,"repas"); $taille=odbc_result($rs,"taille"); $couleur=odbc_result($rs,"couleur"); $Nbre_Oeuf=odbc_result($rs,"Nbre_Oeuf"); $Nom_Oiseau=odbc_result($rs,"Nom_Oiseau"); ?> <tr> <td class="contour_cellule"><?php echo $repas; ?></td> <td class="contour_cellule"><?php echo $taille; ?></td> <td class="contour_cellule"><?php echo $couleur; ?></td> <td class="contour_cellule"><?php echo $Nbre_Oeuf; ?></td> <td class="contour_cellule"><?php echo $Nom_Oiseau; ?></td> </tr> <?php } ?> </table> <?php //free results from memory during script execution //to avoid using too much memory during script execution odbc_free_result($rs); //close ODBC connection odbc_close($conn); ?> </body> </html> 


so my code for the dropdown was good, but I couldn't refresh the table, which my script now allows me to do...

..But (because there is a but!):

1) I have a layout issue; I can't get my header row (HTML) in the same table as the results from my query (PHP)... I managed to split my code into two pages, and I would like to keep it that way... does anyone have a solution to this problem?

2) moreover, I would like the table to display all results from the query by default without considering the dropdown (that is to say all the birds, regardless of size...), because for now, I have to select a bird size in my table for any result to appear. I think something like this:

 <td class="contour_cellule"><select name="categorie" onchange="MAJ(this.value);"> <option value="">Selectionnes une categorie:</option> <option value="gros;moyen;petit">Gros</option> <option value="moyen">Moyen</option> <option value="petit">Petit</option> </select></td> 


..but it works ^^, knowing that ultimately my dropdown will be the result of a query and not hard-coded... well I'm stopping here for now ^^
0
vordano Posted messages 1981 Status Membre 316
 
Hi,

I see you're using ODBC, are you using Access for the database or what :x ?

Personally, I would like something like this:
 <script type="text/javascript"> function MAJ(str) { var ajax; ajax=new XMLHttpRequest(); ajax.onreadystatechange=function() { if (ajax.readyState==4 && ajax.status==200) { check this out -> http://www.siteduzero.com/tutoriel-3-36169-xajax-applications-ajax-faciles-avec-php-et-xajax.html you need to fetch your bird list with your li actually your php function will return a preformatted string. document.getElementById("liste_oiseau").innerHTML=ajax.responseText; } } ajax.open("GET","oiseau.php?q="+str,true); ajax.send(); } </script> <!--write your html code for the list of sizes with php to retrieve the sizes, then you have an onChange (or onClick I don't remember) event that calls the MAJ function <?php $res=odbc_exec($con,"SELECT * FROM T_Oiseau"); echo "<ul>"; echo "<div id=\"liste_oiseaux\">"; while($oiseau=odbc_fetch_array($res){//not sure if odbc_fetch_array exists echo "<li>".$oiseau['taille']."</li>"; echo "<li>".$oiseau['repas']."</li>"; //and others... } echo "</div>"; echo "</ul>"; ?> 

say no to draconian laws (Hadopi, SOPA, PIPA, Arjel, ACTA, IPRED) and digital censorship!!!
0
tsig00 Posted messages 20 Registration date   Status Membre Last intervention  
 
Hello, and thank you for your response...

- Yes, I use ODBC; I work with SQL through an ERP called Excalibur. I picked up the work already done during my internship, and I don't know any other methods in my case, but I'm open to any suggestions :).

- I read the topic on the Site du Zéro about Xajax... interesting, but my JS script works, and I don't see the point of reworking it in Xajax... or I didn't really grasp the interest of that link...

- As for:
"" $oiseau=odbc_fetch_array($res)"", it works very well, yes, but putting it in <li> tags is not of interest to me either, as I want to fill the table defined by my HTML page...

So I didn't grasp the extent of your arguments, or maybe I formulated my problem poorly:

1) My code works; I only have a layout issue. I modified it so that it appears in the same table by repeating the <tr> title of the table in the PHP page, but when I execute it, the result gives me 2 tables: that is to say, when I open my HTML page, I have the title and my table (empty) with my dropdown list in a cell of the table, but when I choose a value from my dropdown list, the PHP page table appears (all correctly) but just below, the <tr> title of the HTML page remains. I'm thinking of a script to make it disappear onchange or onclick, as you say... I'll show you my PHP page that gives this result:

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=windows-1250"> <meta name="generator" content="PSPad editor, www.pspad.com"> <link href="../style2.css" rel="stylesheet" type="text/css"> <title></title> <?php $q=$_GET["q"]; //connecting to the database $conn=odbc_connect('','',''); //connection test if ($conn==false) {die("connection failed");} //query based on the dropdown list choice $sql="SELECT * FROM T_Oiseau WHERE taille = '$q') "; //execute the query $rs=odbc_exec($conn,$sql); $i = 0 ; ?> <!-- Title row of the table --> <table class="contour"> <tr class="titre"> <td class="contour_cellule">age</td> <td class="contour_cellule">repas</td> <td class="contour_cellule"><select name="categorie onchange="MAJ(this.value);"> <option value="">Select a category:</option> <option value="gros">Large</option> <option value="moyen">Medium</option> <option value="petit">Small</option> </select></td> <td class="contour_cellule">Color</td> <td class="contour_cellule">Nbre_Oeuf</td> <td class="contour_cellule">Nom_Oiseau</td> </tr> <?php //loop through the DB to retrieve all rows while(odbc_fetch_row($rs)) { $repas=odbc_result($rs,"repas"); $taille=odbc_result($rs,"taille"); $couleur=odbc_result($rs,"couleur"); $Nbre_Oeuf=odbc_result($rs,"Nbre_Oeuf"); $Nom_Oiseau=odbc_result($rs,"Nom_Oiseau"); ?> <tr> <td class="contour_cellule"><?php echo $repas; ?></td> <td class="contour_cellule"><?php echo $taille; ?></td> <td class="contour_cellule"><?php echo $couleur; ?></td> <td class="contour_cellule"><?php echo $Nbre_Oeuf; ?></td> <td class="contour_cellule"><?php echo $Nom_Oiseau; ?></td> </tr> <?php } ?> </table> <?php //to free up results in memory during script execution //to avoid using too much memory while executing the script odbc_free_result($rs); //closes odbc connection odbc_close($conn); ?> </body> </html> 


the PHP page comes to be added to the HTML page... which gives a not very nice result...

2) As for the startup page with a table already filled, I thought about adding a page that contains the filled table and calls the HTML page on changing values of the dropdown list.. but I am all ears to do that in just my two pages.. if any areas remain unclear, I am at your disposal.
0
vordano Posted messages 1981 Status Membre 316
 
Actually, the interest I see in xAjax (according to the tutorial) is to be able to use a very specific method, and therefore return a value (for example your list of birds for a dropdown list or something else).

After rereading, and if I understand correctly, you want to do something like this:
 <table class="contour"> //column title <tr class="titre"> <td class="contour_cellule">age</td> <td class="contour_cellule">meal</td> <td class="contour_cellule"><select name="category onchange="MAJ(this.value);"> <option value="">Select a category:</option> <option value="large">Large</option> <option value="medium">Medium</option> <option value="small">Small</option> </select></td> <td class="contour_cellule">Color</td> <td class="contour_cellule">Number_Egg</td> <td class="contour_cellule">Bird_Name</td> </tr> <?php //loop the DB to retrieve all rows while(odbc_fetch_row($rs))//content of the columns. generation of birds of all sizes upon page load, and selection of birds according to the size chosen in the dropdown list { $meal=odbc_result($rs,"meal"); $size=odbc_result($rs,"size"); $color=odbc_result($rs,"color"); $Number_Egg=odbc_result($rs,"Number_Egg"); $Bird_Name=odbc_result($rs,"Bird_Name"); ?> <tr> <td class="contour_cellule"><?php echo $meal; ?></td> <td class="contour_cellule"><?php echo $size; ?></td> <td class="contour_cellule"><?php echo $color; ?></td> <td class="contour_cellule"><?php echo $Number_Egg; ?></td> <td class="contour_cellule"><?php echo $Bird_Name; ?></td> </tr> <?php } ?> </table> 
0
tsig00 Posted messages 20 Registration date   Status Membre Last intervention  
 
Yes, that's exactly what I want^^
As for the dynamic dropdown list, I managed to integrate it but I have an issue with the value not being recognized by my JS function :maj(). Furthermore, it appears on the HTML page... I'll read the xajax tutorial more thoroughly. :)

This issue is secondary for now; I'm focusing on displaying the table: you have indeed understood the purpose of my maneuver, my concern being that when I select a value from the dropdown list, my query executes, making the table appear with title and PHP content, but the table with just the title (without content from the HTML page) remains at the bottom of the page: I end up with 2 tables.

Another issue is that when I refresh my HTML page, the table is empty; I would like the page to refresh to show the complete table by default...
In my :
 $sql="SELECT * FROM T_Oiseau WHERE taille = '$q') "; 

I would also like the variable $q to take all values, all sizes (meaning to display the entire table). To add to the dropdown list the possibility to re-display the entire table without having to refresh the page... I've tried with:
$q = *;
$q="gros;moyen;petit" ;
$q = %;
nothing works for now...
0
vordano Posted messages 1981 Status Membre 316
 
For your request:
$q="%";
$sql="SELECT * FROM T_Bird WHERE size like '$q') ";

first, you need to display the list of birds without size distinction with your PHP.
your list of birds (your bird array) will be surrounded by a div with, for example, list_bird as the id
then you have an event on your dropdown list that will change the HTML located between the div list_bird. you generate the new HTML in whatever way you want with XMLHttpRequest (personally, it's a call to a PHP function that returns text to me, but I don't know if that can be done via GET...)

am I correct?
0
tsig00 Posted messages 20 Registration date   Status Membre Last intervention  
 
Thank you, I'm doing my little tests, it might take some time... but I'm on it :) As for the '%', it's not working... probably a syntax error... I'll probably repost after the meal^^
0
tsig00 Posted messages 20 Registration date   Status Membre Last intervention  
 
Ok, well it's not great but I managed to save the casing^^
for:
$sql="SELECT * FROM T_Bird WHERE size like '$q') ";
well that's not working and I have a hard time explaining it...(maybe the ERP is blocking it) anyway I initialized a variable that concatenates the different possibilities (not great but it works for now)

As for the more difficult part... well I didn't manage to fit everything into my table with my two pages.. I booked the xmlhttprequest method which seems like a good idea but I still have too many gaps for now I'll have to go through a lot more tutorials before I can see the light...
but good news (yes, indeed^^) by putting everything on one table I managed to get what I wanted which is a single, unique table that displays what I ask of it.. since it's an intranet there isn't much risk in terms of security.. I'm disappointed not to have done all this more neatly but I have a bit of a headache now^^

Still left is the issue of the first page displaying an empty table... although with the dropdown list there was no problem. I tried with selected in the option tag but that doesn't work it doesn't take the value despite the fact that it displays the selected choice correctly... so I'll look into that a bit... if any idea comes up, the tutorial remains open.
0
vordano Posted messages 1981 Status Membre 316
 

$sql="SELECT * FROM T_Bird WHERE size like '%') ";

1) Are you able to display all your birds when your PHP page loads? (that's the main thing)

2) If yes, can you return the correct result with your JavaScript function? (for example, the list of all birds of size 'small', with 'small' being hardcoded in the code for testing purposes)

3) If yes, you need to be able to replace the HTML generated by the PHP with the HTML generated by the JavaScript.
0
tsig00 Posted messages 20 Registration date   Status Membre Last intervention  
 
1) Yes, for the select, I hardcoded my data, I tried a lot of things and I instantiated it like this:
$touteTaille ="big' or size = 'medium' or size = 'small";

and in the dropdown list:
<option value="<?php echo $touteTaille ?>">All sizes</option>

it's good, it works. But as I said, I can't load everything on load, I have to select 'All sizes' from the dropdown list...

2) Yes, clearly I get it when it's hardcoded in the dropdown list... (...well... when you say hardcoded in the JavaScript code, do you mean hardcoded in the SQL query? Otherwise, I don't see)

3) On that, I don't quite understand... my JavaScript code is just a function that updates my query based on my dropdown list... my query is in PHP... and it displays in HTML the PHP variables coming from my query... that's how I understand it...
so I don't see the HTML generated by the JavaScript, I think you're too skilled, I couldn't manage to leverage the XMLHttpRequest function if that's what you're referring to...
0
vordano Posted messages 1981 Status Membre 316
 
I'm not expressing myself well (or I'm misunderstanding the request)

Actually, what I would do is, on one side, display all the birds with PHP (the basic thing, doing a select of all your birds without size distinction)

And then you have your dropdown list generated independently from your list of birds, which contains all the sizes. This list has a JavaScript event that calls your MAJ function

This MAJ function generates the same list of birds, but with the size taken into account (so you have the complete HTML with the <td> etc...)

And to replace the HTML (in your JavaScript function), I think you just need to wrap your <table> ... </table> in a div (in your HTML)

Am I making myself clear or is it confusing?
0
tsig00
 
lol getting better and better ^^
but the problem is that it's a display screen and I have to save as much space as possible for ergonomic reasons, it's essential for my project to integrate the dropdown list with the table title.... I was thinking of following your reasoning and creating a second page that redirects onchange to the one that works... I'll try this route. It's crazy that the default value doesn't work.. but it would obviously be too simple.
0
vordano Posted messages 1981 Status Membre 316
 
attention, I never said to create a second page with a redirection on the onchange event !!!!

I am just repeating the same code for a while now ^^
Reread the code I made (and just modified)
You might understand better. You just need to change the HTML directly with JavaScript
<script type="text/javascript">
function MAJ(str)
{
var ajax;

ajax=new XMLHttpRequest();

ajax.onreadystatechange=function()
{
if (ajax.readyState==4 && ajax.status==200)
{

document.getElementById("liste_oiseau").innerHTML="<tr><td>NEW BIRD PIAFFFFFFFFFFFFFFF</td></tr>";
}
}
ajax.open("GET","oiseau.php?q="+str,true);
ajax.send();
}
</script>
<!--write your html code for the list of sizes with php to retrieve the sizes, then you make a onChange (or onClick I don't remember) event that calls the MAJ function
<?php
$res=odbc_exec($con,"SELECT * FROM T_Oiseau");
echo "<table>";
echo "<div id=\"liste_oiseaux\">";
while($oiseau=odbc_fetch_array($res)){//not sure if odbc_fetch_array exists

echo "<tr><td>".$oiseau['taille']."</td>";
echo "<td>".$oiseau['repas']."</td></tr>"; //and others...
}
echo "</div>";
echo "</table>";
?>
0
tsig00 Posted messages 20 Registration date   Status Membre Last intervention  
 
Ok, thanks for your advice. I’ll go back to my database on Monday, I’ll try to do this at home on another database… in the meantime, have a great weekend!
0
tsig00 Posted messages 20 Registration date   Status Membre Last intervention  
 
Well, I've found a solution that seems more accessible and works for me on another database
 $connexion = mysql_connect("localhost", "", "") or die("Unable to connect: " . mysql_error()); //database selection mysql_select_db("test"); if (!empty($_GET["q"])) { $q=$_GET["q"]; //query based on the dropdown selection $sql="SELECT * FROM T_Oiseau WHERE taille = '$q'"; } else { //query based on the dropdown selection $sql="SELECT * FROM T_Oiseau"; } //Execute the query $resultats = mysql_query($sql); ?> 


It seems almost too easy^^ but since it's not on the "onchange" event, the table loads upon page refresh... I'll try this on Monday and keep you updated if it works..and I'll call for help if it doesn't^^
0
tsig00
 
ok it works very well! now I just need to make several dropdown menus coexist.. but that's just a matter of queries and a few hundred liters of coffee^^...
I have another issue which is to replace my dropdown menu with more search options, similar to what Excel offers, but I will post a new topic and declare this one as resolved... if I find out how to do it :)!
thank you again vordano!
++
0