Jump to content

Need Help with a Seemingly Simple Task


maat

Recommended Posts

Hello,

 

I have come to a dead end. What I'm trying to do is simple: have a dynamic title for my php page (something that would be executed by, for example,

<title><?php echo $title; ?></title>

).

 

I'm not an experienced coder. I've tried about 15 different variations to try to achieve the result I want, and none of them have worked.

 

I'm using a dynamic web template (DWT), which has editable regions for the

<title>

section and for the main body of the webpage. I'm also using a Smarty template, called display_post.tpl, which, along the php file that is attached to the DWT, called display_post.php, are provided below as originally written:

 

Smarty template:

 

<table cellpadding="8">
<tr>
<td valign="top">

{section name=mysec loop=$posts}
<h2>{$posts[mysec].title}</h2><br>
{$posts[mysec].body|nl2br}
<br>
{/section}
</td>
</tr>
</table>

 

display_post.php:

 

<?php
require_once('db_login.php');
require_once('config.php');

$conn = mysqli_connect($db_host, $db_username, $db_password, $db_database) or die    ('Error connecting to MySQL');

$post_id = $_GET['post_id'];

$query = "SELECT * FROM posts WHERE post_id=$post_id";
$result = mysqli_query($conn, $query);

while($row = $result->fetch_array()){
$test[] = $row;
}

$smarty->assign('posts', $test);
$smarty->display('display_post.tpl');

mysqli_close($conn);

?>

 

Everything works as is. Part of the problem is that I don't know whether to do this through the DWT/php file or through Smarty. I've tried variations on both approaches, which I can provide for food-for-thought if need be. For now, I would love to read any possible solutions that you can come up with.

 

Thanks bunches!  :D

Maat

 

Link to comment
https://forums.phpfreaks.com/topic/247922-need-help-with-a-seemingly-simple-task/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.