[Solved] php dynamically generate new web page from link [closed]


Assuming each of the articles has its ID. Change the link to go to a dynamic page, passing that ID:

"<div class=\"title\"><a href=\"dynamic_page.php?id=$result[id]\">$resultphp dynamically generate new web page from link [closed]</a></div>"

Then create a dynamic_page.php that accepts that ID and generates the article as follows:

if (isset($_GET['id'])) {
    $id = mysql_real_escape_string($_GET['id']);
    $q = "SELECT
            *
        FROM
            `article`
        WHERE
            `id` = '$id'
        LIMIT 1;";
    $q = mysql_query($q);
    if (mysql_num_rows($q) > 0) {
        $result = mysql_fetch_assoc($q);
        echo "<div class=\"article\">".
                "<div class=\"title\">".$result['title']."</div>".
                "<div class=\"body\">".$result['body']."</div>".
                "<div class=\"cat\"><a href=\"".$result['cat'].".php"."\">"."Category: ".$result['cat']."</a></div>".
                "<div class=\"author\">"."Author: ".$result['author']."</div>".
                "<div class=\"dateTime\">"."Date: ".$result['date']."</div>".
            "</div>";
    }
    else {
        /* Article not found */
    }
}

Note that the $result['body'] is shown in full this time. Also I suggest using mysql_fetch_assoc() in your case.

The code is here

2

solved php dynamically generate new web page from link [closed]