Forum Moderators: coopster
www.yoursite.com/?p=home
www.yoursite.com/?p=services
So that the navigation calls up the relevant page. However when I type:
www.yoursite.com - It comes up with no data because none has been called...
Does anyone know how to set it up so if you go to
www.yoursite.com it goes to say the default home page?
Thanks in advance!
Also can anyone help with changing /?p=home ot a permalink:
/home/
/services/
etc?
Here is the code in the index.php:
<?
include("/includes/config.php");
include("/library/config.php");
include("/library/opendb.php");
$pagename=$_POST['p'];
$query=" SELECT * FROM pages WHERE pagename = '{$_GET['p']}'";
$result=mysql_query($query);
$num=mysql_num_rows($result);
$i=0;
while ($i < $num) {
$id=mysql_result($result,$i,"id");
$pagename=mysql_result($result,$i,"pagename");
$content=mysql_result($result,$i,"content");
?>
<?php
if (get_magic_quotes_gpc())
{
$content = stripslashes($content);
}
?>
<? echo "$content"?>
<?
++$i;
}
?>
For the pages that you want to redirect you can use the following...
www/html/index.php
<?php
//redirect this page to your actual homepage
header("Location: [yoursite.com...]
?>
this method can be used for your other pages as well...
hope this answered your questions
However firefox gives me this message and all cookies are enabled?
The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for this address in a way that will never complete
* This problem can sometimes be caused by disabling or refusing to accept
cookies.
header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
if this doesn't work then i don't know...sorry
i hope you get it
$pagename=$_POST['p'];
$query=" SELECT * FROM pages WHERE pagename = '{$_GET['p']}'";
I don't know why you have $_POST assigned first and then unused. I am guessing that means it is unneeded. I also don't understand why $pagename is set a again later.
$pagename=mysql_result($result,$i,"pagename");
I also don't really understand the need for num rows and the loop. My thought is that it should only ever return a single row. You should be able to default it like alce showed
I would do something like this
<?
include("/includes/config.php");
include("/library/config.php");
include("/library/opendb.php");
$pagename = '';
if (!isset($_GET['p']) ¦¦ empty($_GET['p'])) $pagename = 'home';
else $pagename = $_GET['p'];
$query="SELECT * FROM pages WHERE pagename='" . $pagename . '";
$result=mysql_query($query);
if ($row = mysql_fetch_array($result)) {
$id = $row['id'];
$content = $row['content'];
if (get_magic_quotes_gpc()) $content = stripslashes($content);
echo "$content";
}
?>
that removes the loop but there shouls only be a single row per page. The rest should work.
remember that ¦ is not a real pipe char and must be replaced with a real pipe char before testing this code