Hi I am finnaly trying to move an external PHP file to MODX as a snippet.
I cant seem to find out how to properly connect to MODX with that script.
The external script reads out dbuser,dbpw etc from an
include(’connections.php’);
But I thougyt I could use something like
Problem is that the script stops here:
$res = mysql_query($query, $sqlConn);
As the $sqlConn var is comming in through the connections.php it would need to be replaced by something like global Modx ?
Any suggestion. I looked into dbapi query but that is still somewhat to abstract for me,
In short how to change this
if ($first_is_number)
$query = "select * from publisher WHERE abbreviation >= '0%' and abbreviation <= '9%'";
else $query = "select * from publisher WHERE abbreviation like '".$pubchar."%'";
$query .= " order by abbreviation ASC";
$res = mysql_query($query, $sqlConn);
To this
$output = '';
$result = $modx->db->query( 'SELECT id, name, joined FROM `user_table` GROUP BY `member_type` ORDER BY name ASC' );
while( $row = $modx->db->getRow( $result ) ) {
$output .= '<br /> ID: ' . $row['id'] . '<br /> Name: ' . $row['name'] . '<br /> Joined: ' . $row['joined']
. '<br />---------<br />';
}
echo $output;