WHMCS Smarty syntax to show total clients - syntax

Is there a Syntax to display total clients in WHMCS (as a number)? If not, is there any way of doing this?

You can use this ode within your template files.
Just put this lines of code within your /templates/yourtemplate/yourfile.tpl
{php}
$query ="SELECT COUNT(id) from tblclients ";
$result = mysql_query($query);
$data = mysql_fetch_array($result);
echo "total clients :".$data[0];
{/php}

You can use getcontacts command for getting the total numbr of clients in WHMCS. You might want to have a look at this document:
http://docs.whmcs.com/API:Get_Contacts

Related

How to echo multiple where clauses in a CI query on screen

I'm attempting to get the results of a database table and echo the query results.
Here is my code:
$queryDB = $this->db->select('*')
->from('dr_template_relational')
->where('value_id', $categoryDetails['value_id'])
->where('subcategory_id', $categoryDetails['subcategory_id'])
->get();
echo "<br>";
echo "here is queryDB";
echo($queryDB);
echo "that was it";
$queryDB doesn't echo even so I'm sure the data is there. I'm wondering what I'm doing wrong. I'm not getting an error, but also don't get any output with echo($queryDB); on screen it displays:
here is queryDBthat was it
Right now, your approach is just echoing out the instance of the query.
In order to see the query results, you need to create them. There are several CI functions like result() and row()
at the end it could look like this:
foreach ($queryDB ->result() as $row){
echo $row->value_id;
echo $row->subcategory_id;
}
see Generating Query Results
hint: in order to see the generated query you could use
echo $this->$db->last_query();

Get whole Property Object from RETS Server using PHRETS

I am getting MLNumbers from RETS Server but now I need to get all the fields of all the MLNumbers and store into my database. Could anybody help me to write query to get the whole property Object.
If you have all the Listing Numbers then you just need to write a search query to pull all the results back and process the results. I haven't ever seen a field name MLNumber but you will have to figure that out:
<?php
$search = $rets->SearchQuery("Property","RES","(MLNumber=11111,22222,33333)");
while ($listing = $rets->FetchRow($search)) {
echo "Address: {$listing['StreetNumber']} {$listing['StreetName']}, ";
echo "{$listing['City']}, ";
echo "{$listing['State']} {$listing['ZipCode']} listed for ";
echo "\$".number_format($listing['ListPrice'])."\n";
}
$rets->FreeResult($search);
I think this should return the results you need. You will need to figure out the Resource/Class/Field name you need to use for your SearchQuery().
More PHRETS examples here.

Getting Order Number from Order Id in Magento?

I am using following code to get the Order Number from Order ID.
$orderId=64; //Order Id will be supplied dynamically
$order = Mage::getModel('sales/order')->load($orderId);
echo "Order Number is: ".$order['increment_id'];
I am getting the correct order number using this code like 100000067.
I wanted to know Is this the correct approach to use.
Please guide.
Thanks
This should work for you.
$orderId = 64;
$order = Mage::getModel('sales/order')->load($orderId);
echo $order->getIncrementId();
Cheers!

syntax error, unexpected T_OBJECT_OPERATOR

I'm a total newbie when it comes to php and mysql/mysqli. I have this code and I get a PHP Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /home/byeroman/public_html/register.php on line 17. Here's the code:
$stmt = mysqli->prepare("SELECT COUNT(*) FROM users WHERE username=? LIMIT 1" or die($db->error()));
$stmt->bind_param("s", $username);
$stmt->execute();
$stmt->store_result();
$count=$stmt->num_rows;
$stmt->close();
if($count>0) exit();
what's wrong? thanks guys
That's silly syntax issue, you just forgot closing brace.
To make such things less possible and also to make your code readable, divide your statements into separate lines:
$sql = "SELECT COUNT(*) FROM users WHERE username=? LIMIT 1";
$stmt = $mysqli->prepare($sql) or trigger_error($mysqli->error()));
You also need to make your mind which variable you're using ($mysqli or $db)
Also, num_rows() is wrong function to use, you need regular fetch instead.
By the way, consider to use some database abstraction library. It can make your life a lot easier and code - shorter, like this (it replaces ALL your code, mind you):
$num = $db->getOne("SELECT COUNT(*) FROM users WHERE username=?",$username);
if($num) { ...

Codeigniter select_avg('columnname') WHERE thisaverage > x

What I want to do is select items from my database where the average review is greater than 7.
$this->db->select_avg('reviews.overall');
That query selects the average review 'as overall'.
Therefore i assumed i could simply then use
$this->db->where('overall>','7');
This however does not work.
ANy ideas?
Thanks
EDIT
Putting in a space
$this->db->select_avg('reviews.overall');
$this->db->where('overall >','7');
Yields the error
Column 'overall' in where clause is ambiguous
It is ambiguous but how am I now meant to reference it??
Thx
It's writen in the codeigniter user manual too:
$this->db->select_avg(); Writes a "SELECT AVG(field)" portion for your query. As with select_max(), You can optionally include a second parameter to rename the resulting field.
If you enable profiler in CI, you would see, what query does this code generate.
Your code is generated like this:
SELECT AVG(reviews.overall) as reviews.overall FROM ....
Use it like this:
$this->db->select_avg('reviews','overall');
$this->db->from('table name');
$this->db->where('overal >', 7);
$Q = $this->db->get();

Resources