-1

i am using smarthsheet api to put some data into sheet with php. Everything working fine. but i need to change the color of a column if it meets the specific condition.

By searching i found a parameter known as formating :
http://smartsheet-platform.github.io/api-docs/?shell#formatting

But i am not sure how to use it. please help in it.

        $dataString.='{"columnId": 799, "value": "'.$this->clean_string($data['routing_number']).'"},';

this is how i am updating the values of column. how i pass formating parameter to change its color. The defalut color is black . i need to change to red .

Sanoj Sharma
  • 127
  • 10

1 Answers1

0

Its been awhile since this question was asked, I've had it open since it was asked but only now got the time to try it and answer, hopefully the answer is still helpful :)

Just for clarity I'll explain my assumptions

My solution takes input in the form of space separated words, any word entered must exist in the results but can be from either field "business_name or business_description", if no input is given perform a generic query.

I've added some basic sanitization to the input data and simplified the code

<?php
$keywords = trim(filter_var($_REQUEST["keywords"], FILTER_SANITIZE_STRING, FILTER_SANITIZE_MAGIC_QUOTES));

$query = "SELECT * FROM business_listing";

if(strlen($keywords) > 0)
{
    $words = explode(" ",$keywords);

    $query .= " WHERE ";
    foreach ($words as $word)
    {
        $safeWord = mysql_real_escape_string($word);
        $query .= "(business_name LIKE '%" . $safeWord . "%' OR business_description LIKE '%" . $safeWord . "%') AND ";
    }
    $query = rtrim($query, " AND");
}

echo $query;

?>

You can run this by the following argument in a url if the php was saved to a file search.php

search.php?keywords=gopher test fish

This would produce the following SQL statement

SELECT * FROM business_listing WHERE (business_name LIKE '%gopher%' OR business_description LIKE '%gopher%') AND (business_name LIKE '%test%' OR business_description LIKE '%test%') AND (business_name LIKE '%fish%' OR business_description LIKE '%fish%')

For the santa napa request from Sanoj Sharma it would produce

SELECT * FROM business_listing WHERE (business_name LIKE '%santa%' OR business_description LIKE '%santa%') AND (business_name LIKE '%napa%' OR business_description LIKE '%napa%')
duindain
  • 525
  • 3
  • 12