following this tutorial here: http://docs.joomla.org/Selecting_data_using_JDatabase#Selecting_Records_from_a_Single_Table
I have created a function as follows:
function getItemForBid() {
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
// Select item record matching the $orderID
$query
->select($db->quoteName(array('id', 'created_by', 'itemtitle', 'deliverydestination', 'listprice')))
->from($db->quoteName('#__entrusters_items'))
->where('id = '.$_GET['orderID']);
// Reset the query using our newly populated query object.
$db->setQuery($query);
// Load the results as a list of stdClass objects (see later for more options on retrieving data).
$db->setQuery($query);
$bidItem = $db->loadObject();
//print_r($bidItem);
}
The print_r($bidItem);
works and returns e.g.:
stdClass Object (
[id] => 4
[created_by] => 216
[itemtitle] => Tennis Racket
[deliverydestination] => London
[listprice] => 5000
)
however if I try to echo one of the values elsewhere on the page i.e. like this:
<input name="jform[item_id]" id="jform_item_id" value="<?php echo $bidItem->id; ?> " readonly="" type="text">
I get nothing. The manual says you can access the individual values by using:
$result->index // e.g. $result->email
Am I doing something very stupid?