Re: New PHP User with a simple question
| From: | Jason Pruim | Date: | Sun, 25 Jan 2009 14:57:15 +0000 |
| Subject: | Re: New PHP User with a simple question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-287101@lists.php.net to get a copy of this message | ||
On Jan 24, 2009, at 11:06 PM, Christopher W wrote:
At least I hope it is simple... I am trying to get an HTML menu link to set a variable's value. For example, when a user clicks the "Home" button on my page it would cause $page = "home"; or clicking the "About Us" button will set $page="about_us"; etc. I think this should be fairly simple but being completely new to php I just cannot seem to get it right. Any help would be greatly appreciate.Hi Christopher, Here's a code sample of something that I use to change the page without reloading the entire thing... It is in the proces of developing into somewhat of a template system where the presentation info (The look of the site) is included in one file, and then when a link is clicked it loads in the actual content for that page. Let me know if you have any questions about it. <?PHP
include("php.ini.php");
include("dbconnect.php");
include("defaults.php");
include("doctype.txt");
include("main.css");
$link = dbconnect($server, $username, $password, $database);if(!isset($data)) {
$data = explode("/", $_SERVER['REQUEST_URI']);
}
// Used for grabbing which page to bring in to include
$url = basename($_SERVER['REQUEST_URI']);
$sql = "SELECT * from raosetc_purl.schreur where url='{$data[1]}' AND subscribed='0';";
$row[] = mysql_query($sql) or die("Database Error: " .mysql_error());
$result = $row[0];
//Navigation must be below call to $data for it to function properly
include("nav.php");
while($row = mysql_fetch_assoc($result)){
echo <<<HTML
<body>
<div class="wrapper">
<div class="text">
<h1 class="white">{$row['FName']}! It's great to see you!</h1>
<!--[if lte IE 7]>
<div style="position:relative; height: 105px; width: 206px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader
(src='HTTP://purl.raoset.com/media/SPC.logo.new.png',sizingMethod='scale');"></div>
<![endif]-->
<img class="logo" src="HTTP://purl.raoset.com/media/SPC.logo.new.png" width="250px" height="auto" ALT="SPCLogo"> HTML; switch($url) { case "design"; include("design.php"); //$purl = $data['1']; break; case "print"; include("print.php"); break; case "mail"; include("mail.php"); break; case "purl"; include("purl.php"); break; case "test"; include("body.test.php"); break; case "thankyou"; include("thankyou.php"); break; default; include("body.php"); break; }
}echo <<<HTML
</div><!--End of text div -->
</div><!-- End of wrapper div -->
</body>
HTML;
?>