troubleshooting Question

reading from a mysql table and use that as a parameter second query

Avatar of TonyReba
TonyRebaFlag for United States of America asked on
PHPJoomlaSQL
4 Comments1 Solution344 ViewsLast Modified:
I am trying to pull Descr from a a table called jos_dept_codes , which would look for a result  from a 1st querie  , I made a variable called deptcode for this but is not pulling anything,. no error but just not output.
$database =& JFactory::getDBO(); 

// to do GET QUERY STRING OR POST DATA....... 
$database->setQuery('SELECT department FROM jos_dhruprofile WHERE uid = 325 ') ;
//echo $database->loadResult();
 
if (!$database->query()) { //write data and if error occurs alert
    echo "<script> alert('".$database->getErrorMsg()."'); </script>";
}
//var_dump($database);
//$row = $database->loadRowList();
// Set New Var

$deptcode =  $database->loadResult();

 $db2 =& JFactory::getDBO(); 
 $db2->setQuery('SELECT Descr FROM jos_dept_codes WHERE code = $deptcode  ') ;
 
 
      ?>
      <input class="label" type="text" name="email" id="email" size="40" value="<?php echo $db2->loadResult(); ?>" />
     </td>
    </tr>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros