We help IT Professionals succeed at work.
Get Started

How can i implement my own mysql query into an JOOMLA 2.5 page

Solenthaler
Solenthaler asked
on
1,614 Views
Last Modified: 2012-07-22
Must implement the following mySQL query-code into an Joomla Article:
-----------------------------------------------------------------------------------------
Here is my code example (the complete code is attached) this is the ->index.php

<?php
  include('db.php');
  include('func.php');
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Chained Select Boxes using PHP, MySQL and jQuery</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>

<script type="text/javascript">
$(document).ready(function() {
      $('#wait_1').hide();
      $('#drop_1').change(function(){
        $('#wait_1').show();
        $('#result_1').hide();
      $.get("func.php", {
            func: "drop_1",
            drop_var: $('#drop_1').val()
      }, function(response){
        $('#result_1').fadeOut();
        setTimeout("finishAjax('result_1', '"+escape(response)+"')", 400);
      });
          return false;
      });
});

function finishAjax(id, response) {
  $('#wait_1').hide();
  $('#'+id).html(unescape(response));
  $('#'+id).fadeIn();
}
</script>
</head>

<body>
<p>
<form action="" method="post">
 
    <select name="drop_1" id="drop_1">
   
      <option value="" selected="selected" disabled="disabled">Select a Category</option>
     
      <?php getTierOne(); ?>
   
    </select>
   
    <span id="wait_1" style="display: none;">
    <img alt="Please Wait" src="ajax-loader.gif"/>
    </span>
    <span id="result_1" style="display: none;"></span>
 
</form>
</p>
<p>
<?php if(isset($_POST['submit'])){
      $drop = $_POST['drop_1'];
      $tier_two = $_POST['tier_two'];
      echo "You selected ";
      echo $drop." & ".$tier_two;
}
?>
<p><a href="three-tier/">View 3 Tier Select Box Example</a></p>
</body>
</html>
---------------------------------------------------------------------------------------
Is there an elegant way. I did never implement own DB Queries into Joomla.
The DB-Part is a new table in Joomlas Main DB.
1. How is the connection to the table done?
2. Is there an other issue with the DB?
3. Where must the PHP-Code be implemented?
Regards
Roland
index.php
func.php
db.php
Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE