jameschambers Posted June 8, 2006 Share Posted June 8, 2006 HiAs I'm sure you will be able to tell, I'm very new to this whole php thing. I'm basically trying to set up a really simple CMS, one in which a list of topic titles is displayed in an a menu on the left, then when you click on the title it brings up the whole 'article'. The code here is code taken from an existing cms and modified, but as i say i'm pretty new to this and have come to a bit of a dead end.the header.php is included on every page, and is the 'menu' part of it.the page.php is the script i want to display the individual articles.I know i need to pass the ID for the specific article to the page.php but am at a bit of a loss as to how to do it.Very grateful for any help[b]header.php[/b]<?php if (!isset($_REQUEST['page'])&&!isset($_REQUEST['story'])) $page = 'news'; $story = intval($_REQUEST['story']); include_once('db_fns.php'); $handle = db_connect(); if($story) { $query = "select * from stories where id = '$story' and published is not null"; } else { $query = "select * from stories where page = '$page' and published is not null order by published desc"; } $result = $handle->query($query); while ($story = $result->fetch_assoc()) { // headline echo "<ul id='homemenu'>"; echo "<li><a href='page.php?id=$story'>{$story['headline']}</a></li>"; echo "</ul>"; } ?>[b]page.php[/b]<?php if (!isset($_REQUEST['page'])&&!isset($_REQUEST['story'])) { header('Location: index.php'); exit; } $page = ($_REQUEST['page']); $story = intval($_REQUEST['story']); include_once('db_fns.php'); include_once('header.php'); $handle = db_connect(); if($story) { $query = "select * from stories where id = '$story' and published is not null"; } else { $query = "select * from stories where page = '$page' and published is not null order by published desc"; } $result = $handle->query($query); while ($story = $result->fetch_assoc()) { // headline echo "<div id='contentouter'>"; echo "<h2>{$story['headline']}</h2>"; //picture if ($story['picture']) { echo '<div style="float:right; margin:0px 0px 6px 6px;">'; echo '<img src="resize_image.php?image='; echo urlencode($story[picture]); echo '&max_width=900&max_height=900" align = right/></div>'; } // byline $w = get_writer_record($story['writer']); echo '<br /><p class="byline">'; echo $w[full_name].', '; echo date('M d, H:i', $story['modified']); echo '</p>'; // main text echo $story['story_text']; } echo "</div>";?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.