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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.