mysql - How to Display Joomla database table using native joomla 2.5 php objects -


i trying display data mysql database table using native joomla php objects, can never work right. never displays data.

i know how display data connecting database old fashion way, below...

$con = mysqli_connect("localhost","xxxxxx_user10","$dbpass","xxxxxxx_final"); // check connection if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } else { //what base model $sku = $finish; // select correct table $result = mysqli_query($con,"select * bah_finish color_value='$sku' group uniqueid order uniqueid asc");   $row = mysqli_fetch_array($result);   $finishname = $row['color_name'];   $finishtype = $row['color_type']; 

however i'd display content have above, using joomla native php objects, iv'e created sample php table following fields.....

| id | last | first | address | city | state | zip 

and tried display (all rows) / or (one row) using following joomla code.....but nothing happens....no matter how try switch or change out parts of code....so thinking i'm missing fundamental part of how should work....thanks again help! please not quote joomla 2.5 component tutorial joomla.org...that i've gotten code , imo lacks lot of information.

<?php  // db connection. $db = jfactory::getdbo();  // create new query object. $query = $db->getquery(true);  // select records user profile table key begins "custom.". // order ordering field. $query->select($db->quotename(array('last', 'first', 'address', 'city', 'state', 'zip'))); $query->from($db->quotename('111testnames')); $query->where($db->quotename('last') . $db->quote('buffet'));  // reset query using our newly populated query object. $db->setquery($query);  // load results list of stdclass objects (see later more options on retrieving data). $results = $db->loadobjectlist();  echo $results;  ?> 

you have correct: $query->from($db->quotename('111testnames'));

to $query->from($db->quotename('#__111testnames'));

using #__ automatically adds suffix of table.

another error see clause doesn't have have operator. please try correct $query->where($db->quotename('last') ." = ". $db->quote('buffet'));.

in order have proper view of results have use print_r($results); instead of echo $results; there object array have display not string.

good luck!


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -