D
D
Drold2015-12-02 19:01:34
PHP
Drold, 2015-12-02 19:01:34

How to output a different value if $row is empty?

Hello, I'm so-so in PHP .., so the question is:
There is a code that takes a value in the database from the "link" field.

$tpl->set("{вывод-тега}",stripslashes($row['ссылка']));

So, if the field "link" in the database is empty, is it possible to draw another field "link 2"?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Muhammad, 2015-12-02
@Drold

$value = array_key_exists('ссылка', $row) ? $row['ссылка'] : $row['ссылка2'];
$tpl->set("{вывод-тега}",stripslashes($value));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question