Using PHP to create dynamic pages
Posted: Mon Nov 22, 2010 12:31 am
Hi,
I am trying to figure out how to use Wordpress to generate pages dynamically from a database.
If I wanted to post content from my database to a wordpress page dynamically would I do it like this
would I put these into the template.php file
Would I also need to put in some HTML fields into the template.php for the content to show?
Sorry I am really new to php lol and I am trying to learn.
Also here is the template.php code
I am trying to figure out how to use Wordpress to generate pages dynamically from a database.
If I wanted to post content from my database to a wordpress page dynamically would I do it like this
would I put these into the template.php file
Code: Select all
$dbc = mysql_connect('localhost', 'username', 'password');
mysql_select_db("database");
$query_content = "SELECT * FROM content_table WHERE item = '$result'";
$result = mysql_query($query_content);
echo ($result);
Sorry I am really new to php lol and I am trying to learn.
Also here is the template.php code
Code: Select all
<?php get_header(); ?>
<div class="breadcrumbs">
<p><?php if ( get_option( 'ptthemes_breadcrumbs' )) { yoast_breadcrumb('',''); } ?></p>
<span class="findproperties" onclick="show_hide_propertysearchoptions();"><a href="javascript:void(0);"><?php _e(FIND_PROPERTIES_TEXT);?></a></span>
</div>
<?php require_once (TEMPLATEPATH . '/library/includes/search.php'); ?>
<div class="contentarea">
<div id="content" class="content content_<?php echo stripslashes(get_option('ptthemes_sidebar_left')); ?>">
<h1 class="page_head"><?php the_title(); ?></h1>
<?php if(have_posts()) : ?>
<?php while(have_posts()) : the_post() ?>
<?php $pagedesc = get_post_meta($post->ID, 'pagedesc', $single = true); ?>
<div id="post-<?php the_ID(); ?>" >
<div class="entry">
<?php the_content(); ?>
</div>
</div><!--/post-->
<?php endwhile; else : ?>
<div class="posts">
<div class="entry-head"><h2><?php echo get_option('ptthemes_404error_name'); ?></h2></div>
<div class="entry-content"><p><?php echo get_option('ptthemes_404solution_name'); ?></p></div>
</div>
<?php endif; ?>
</div> <!-- content #end -->
<div class="sidebar sidebar_<?php echo stripslashes(get_option('ptthemes_sidebar_left')); ?>">
<div class="sidebar_top">
<div class="sidebar_bottom clearfix">
<?php if (function_exists('dynamic_sidebar') && dynamic_sidebar(4) ) ?>
</div>
</div>
</div>
</div> <!--contentarea #end -->
<?php get_footer(); ?>