Use more than one database table

PicoPaco 07 Jun, 2010
Hi,

I have a ChronoForm where I will have a few dynamic dropdown forms that gets data from database tables. My problem is that I do not know how to do this with more than one table. My code so far:


<?php
$db =& JFactory::getDBO();
$query = "
   SELECT `dnr`
      FROM `upphandling` ;
";

$db->setQuery($query);
$column= $db->loadResultArray();

?>


<?php
$user =& JFactory::getUser(); 
?>

<div class="myform" id="stylized">

<label>Diarienummer</label>
<select name="dnr" size="8">

<?php
foreach ($column as $value)
  {
  echo '<option>'.$value.'</option>';
  }
?>

</select>
    <label>Leverantör</label>
<!-- Below I would like to have the same solution as "dnr" above, but from an other table -->
    <input type="text" name="leverantor" id="leverantor" />

<input type="hidden" name="anv" value="<?php echo $user->username; ?> " id="anv" />

    <input type="submit" class="button" name="submit" id="submit" value="Skapa" />
</div>


It works perfect with one table as the code shows, but I will use the same thing on "leverantor" where the drop down will get data from the table "leverantor". How do I use multiple database-tables in the same ChronoForm?


Thanks

Markus
GreyHead 07 Jun, 2010
Hi Markus,

You can just repeat the code with a different table name and change $column to $column_2 (or some other name).

Bob
PicoPaco 07 Jun, 2010
Thanx Bob,

It was as simple as that!
This topic is locked and no more replies can be posted.