1

My PHP Code

$qry9="SELECT * FROM company_likes WHERE post_id='$pid'";
$result9=mysqli_query($bd, $qry9);
$com_likes= array();
while($row9 = mysqli_fetch_array($result9)){
    $com_likes[]=$row9;
}

and displaying this array in tpl file by:

{section name=b loop=$com_likes}
{/section}

Array $com_likes[] contains both integers and strings and I want to differentiate them. If the value is an integer, use a different link from a string in the tpl file.

Machavity
  • 30,841
  • 27
  • 92
  • 100
kuldeep
  • 11
  • 1

1 Answers1

1

You can use PHP functions to determine if it's an integer or not

{section name=b loop=$com_likes}
    {if $b|is_numeric}Number Link{else}Text Link{/if}
{/section}
Machavity
  • 30,841
  • 27
  • 92
  • 100
  • and how can i echo this 'number' , as a name using SELECT name FROM table WHERE id='number' – kuldeep Jan 04 '18 at 16:22
  • @kuldeep Normally you'd echo it out using something like `{$b}` (using your code). If you need more help than that, check out [this question](https://stackoverflow.com/questions/28316861/passing-variable-from-php-to-smarty) or post a new one with more information – Machavity Jan 04 '18 at 17:04