Show phpmyadmin variable in PHP

0


I want that when editing the variable from the phpmyadmin change here. I hope to explain, because I do not know how to explain it.

echo '$' . $rows_dbpartidos['color_local'] . '';

and it shows a code that I already have organized, for example, "$ celeste" has this RGB: 40, 180, 228

Edit, I have this code:

COLORES.PHP
<?php
$rojo='198, 39, 58';
$azul='33, 62, 113';
$verde='14, 108, 57';
$negro='28, 28, 28';
$granate='123, 43, 63';
$celeste='40, 180, 228';

?>

Y donde quiero poner la variable para editar el codigo lo tengo asi:
<?php
include('colores.php'); 

?>

                          <svg style="width: 100%; height: 100%;position: absolute;">
                              <line x1="15%" y1="110%" x2="70%" y2="-10%" style="stroke:rgb(<?php 
                          $sql_dbpartidos = "SELECT * from equipos where id=1";
                          $result_dbpartidos = mysqli_query($conexion,$sql_dbpartidos);
                          $rows_dbpartidos = mysqli_fetch_array($result_dbpartidos);
                          if($rows_dbpartidos){    
                              echo'' . $rows_dbpartidos['color_local'] .  '';
}
                                ?>);stroke-width:40"></line>
                          </svg>

And in the echo I want to put the editable variable.

    
asked by MatiPHP 22.08.2018 в 00:44
source

1 answer

2

PHP allows the use of variable variables , or in other words, variable names that can be defined and used dynamically.

For example:

echo "$a $$a"; // hola mundo
echo "$a $hola"; // hola mundo

A variable variable takes the value of a variable and treats it as the name of a variable. In the above example, hello, you can use it as the name of a variable using two dollar signs .

To use variable variables with arrays as is the case, we must solve an ambiguity problem, so we must determine which of the two variables refers to the index we indicate, for this we use the keys:

${$a[1]} // pertenece a la variable que da nombre a la variable
${$a}[1] // pertenece a la variable después de haber resuelto el nombre 

Since you have the name of the variable that contains the value you want in an Array, you can do something like this

echo ${$rows_dbpartidos['color_local']};

As an additional note, the variables can be linked and do odd but valid things like this, in which it appears in the manual notes.

$Bar = "a";
$Foo = "Bar";
$World = "Foo";
$Hello = "World";
$a = "Hello";

$a;       //Returns Hello
$$a;      //Returns World
$$$a;     //Returns Foo
$$$$a;    //Returns Bar
$$$$$a;   //Returns a
$$$$$$a;  //Returns Hello
$$$$$$$a; //Returns World
    
answered by 22.08.2018 / 04:54
source