Im using wordpress for a website and i have a problem with these PHP code:
global $wpdb;
$proy = $wpdb->get_results($wpdb->prepare ("select * from proyectos"));
foreach ( $proy as $proyecto)
{
$route = $proyecto->ruta; // THE PROBLEM IS WITH THIS
echo $route;
echo "<div style=background-image: url('".$route."'); class=element data-category=$proyecto->tipo /><p class=number>$proyecto->idP</p><h2 class=name>$proyecto->nombre</h2></div>";
}
So, im creating some divs and i want them to load an image as background. Query is correct, the problem is with the $route.
Making echo $route
shows this: ../wordpress/wp-content/uploads/2013/12/image.jpg
now when i make this: style=background-image: url('".$route."');
and i reload the page it renders this: style=background-image: url('.. wordpress wp-content uploads 2013 12 image.jpg').
It replaces the /
for a blank
.
Please, any help or solutions?
Other valuable info: Im using PHP Code Snippet plugin for wordpress and Chrome browser.
Thank you.