PHP:如何从MYSQL获取信息,使其成为变量并将其放在链接中

Here's my code - not sure what the issue is?

// Make the query:
$query = "SELECT template FROM pages_meta WHERE user_id=$id";  

// RUN THE QUERY
$result = @mysqli_query ($dbc, $q);

$url = 'template';

echo "<link  href=\"$url\" type=\"text/css\" rel=\"stylesheet\" />";

Yes, as said by Jakub, you need to get the data from Mysql and assign to $url.

Do something like this:

$query = "SELECT template FROM pages_meta WHERE user_id=$id";

if ($result = $mysqli->query($query)) {

    /* fetch associative array */
    while ($row = $result->fetch_assoc()) {
        echo '<link  href="'. $row['template'] . '" type="text/css" rel="stylesheet" />';
    }

    /* free result set */
    $result->close();
}

For more: http://www.php.net/manual/en/mysqli-result.fetch-assoc.php

There is in fact a few issues.

You set the variable $query, but use $q in mysqli_query(). By the way, you shouldn't be using @, but rather implement some sort of error handling.

Also, you set url to a string value, meaning that it will simply have the value template. I believe you should set it to something like $result[0]->template, although I'm not completely sure. Try putting the following line in your code and post what it writes out.

var_dump($result);