TOPIC:

URGENT! Display SQL view on page 1 week 16 hours ago #249559

  • Topic Author
  • sprockt012
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 96
  • Thanks: 0
I feel like it's super close but I'm clearly missing something that puts it in to rows as this is what I get - I was hoping for the structure that you seemed to be on to with ITEMNAME: value on each row:

Array ( [0] => stdClass Object ( [LastName] => Last1 ) [1] => stdClass Object ( [LastName] => Last2 ) [2] => stdClass Object ( [LastName] => Last3 ) [3] => stdClass Object ( [LastName] => Last4 ) [4] => stdClass Object ( [LastName] => Last5 ) [5] => stdClass Object ( [LastName] => Last6 ) [6] => stdClass Object ( [LastName] => Last7 ) [7] => stdClass Object ( [LastName] => Last8 ) [8] => stdClass Object ( [LastName] => Last9 ) [9] => stdClass Object ( [LastName] => Last1 ) )



with this code:
<?php
defined('_JEXEC') or die('Restricted Access');

// Get a db connection.
$db = JFactory::getDbo();

// Create a new query object.
$query = $db->getQuery(true);


// Create the base select statement.
$query->select('*')
	->from($db->quoteName('view2_test'));

// Set the query and load the result.
$db->setQuery($query);

$result = $db->loadObjectList();

$items["ITEMNAME"]["value"]=$result;
print_r($result);

?>

Please Log in or Create an account to join the conversation.

URGENT! Display SQL view on page 1 week 16 hours ago #249560

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 1658
  • Karma: 3
  • Thanks: 149
Hi,

and with this:
<?php
defined('_JEXEC') or die('Restricted Access');

// Get a db connection.
$db = JFactory::getDbo();

// Create a new query object.
$query = $db->getQuery(true);


// Create the base select statement.
$query->select('*')
	->from($db->quoteName('view2_test'));

// Set the query and load the result.
$db->setQuery($query);

$result = $db->loadObjectList();

$items["ITEMNAME"]["value"]=$result;
echo $result;

?>

?

Regards,
Tihana

Please Log in or Create an account to join the conversation.

URGENT! Display SQL view on page 1 week 15 hours ago #249561

  • Topic Author
  • sprockt012
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 96
  • Thanks: 0
Now the output is just one word rather than the data:

Array

Please Log in or Create an account to join the conversation.

URGENT! Display SQL view on page 1 week 15 hours ago #249564

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 1658
  • Karma: 3
  • Thanks: 149
ah undestand.
Use print_r instead of echo.

I need to see this better, and then I will get back to you

Regards,
Tihana

Please Log in or Create an account to join the conversation.

SOLVED! Urgent! Display SQL view on page 6 days 11 hours ago #249609

  • Topic Author
  • sprockt012
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 96
  • Thanks: 0
After lots of playing around with the code from above and after adding some tweaks from a PHP forum I found online, I was able to get it working.

Wanted to share with others in case it was helpful.

Long story short...when working with results, I ended up needing to use a "foreach" statement so that I could get the results to show in rows rather than an array.

Thanks again for your help Tihana as it was very useful!

Please Log in or Create an account to join the conversation.

Last edit: Post by sprockt012. Reason: solved

SOVLED! Urgent! Display SQL view on page 6 days 10 hours ago #249611

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 1658
  • Karma: 3
  • Thanks: 149
Hi,

I'm glad to hear that :D

Regards,
Tihana

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
  • 2
Time to create page: 0.052 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

September Discount!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!