Jump to content


New Members
  • Posts

  • Joined

  • Last visited

rbush's Achievements


Newbie (1/5)



  1. Hello, I know this should be pretty simple to figure out, but everything I try is giving me absolutely no results. I have a mysql query selecting columns from my database and returning results. I have the results printing out right now, so I can see that this part is working. All I want to do is take the results and put them into a table to display on my page. Basically, take what's in the database table and copy it to a table I can put on the web. FYI I am using sourcerer so the "connect" code is taken care of for me in the "JFactory" bit of code. Here is the first part of my code, selecting the information from the database. {source} <?php $db = JFactory::getDbo(); $query = $db -> getQuery(true); $query -> SELECT($db -> quoteName(array('first_dept_name', 'last_name', 'dept', 'position', 'phone_num'))); $query -> FROM ($db -> quoteName('#__custom_contacts')); $query -> ORDER ('first_dept_name DESC'); $query -> WHERE ($db -> quoteName('contact_category')."=".$db -> quote('YTown Employees')); $db -> setQuery($query); $results = $db -> loadObjectList(); print_r($results); Here is where I am trying to print the results into a table. I got this code directly from a PHP book, but I am getting nothing at all returned back to me. I get table headers, but no data. <?php echo "<table><tr><th>Name</th><th>Department</th></tr>"; while ($row = mysqli_fetch_array ($result)){ echo "<tr>"; echo "<td>".$row['last_name']."</td>"; echo "<td>".$row['dept']."</td>"; echo "</tr>"; } echo "</table>"; ?> {/source}
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.