V
V
venom19962020-12-15 15:28:48
MODX
venom1996, 2020-12-15 15:28:48

How to use a variable from another modx revo snippet in a snippet?

I have an array stored in one snippet A. I need to get values ​​from it in another snippet. Q. How can I do this? Relatively speaking, include snippet A to snippet B?

//тут подключение к бд

if(!empty($_POST["referal"])){ //Принимаем данные

    $referal = trim(strip_tags(stripcslashes(htmlspecialchars($_POST["referal"]))));

    $db_referal = $mysqli -> query("SELECT * FROM `geo_city`".PREFIX."search WHERE name LIKE '%$referal%'")
    or die('Ошибка №'.__LINE__);

    while ($row = $db_referal -> fetch_array()) {
        echo "\n<li>".$row["name"]."</li>"; //$row["name"] - имя таблицы
    }

}

i need to use $row["name"] in another snippet, how to do it ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alexalexes, 2020-12-15
@alexalexes

https://docs.modx.com/current/en/extending-modx/mo...
Call another snippet from the snippet, passing the required parameters.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question