Jump to content


Photo

Mysql content selector help.


  • Please log in to reply
1 reply to this topic

#1 zbrahead

zbrahead
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 18 May 2006 - 09:47 PM

<?php
Function detectpagecalled($page)
{if($page == home)
{callpagedatahome();}
else
if($page == about)
{callpagedataabout();}
else
if($page == contact)
{callpagedatacontact();}
else
if($page == NULL)
{header("location:index.php?page=home");exit();}
else
if($page != NULL)
{header("location:index.php?page=home");exit();}
}
function callpagedatahome()
	{ $conn = mysql_connect("localhost","******","*******")
				or die("ERR:CONN");
	  $rs = mysql_select_db("pages",$conn)
	  			or die("ERR:DB");
	 $sqlhead1 = 'SELECT * FROM `home` WHERE `variable` like `head1` ';
	  $sqlmsg1 = 'SELECT * FROM `home` WHERE `variable` like `msg1`  ';
	  $sqlhead2 = 'SELECT * FROM `home` WHERE `variable` like `head2` ';
	  $sqlmsg2 = 'SELECT * FROM `home` WHERE `variable` like `msg2` ';
	  
	$rs = mysql_query($sqlhead1,$conn) ;
	  $head1 = Mysql_fetch_array($rs);
	$rs = mysql_query($sqlmsg1,$conn) ;
	  $msg1 = Mysql_fetch_array($rs);
	$rs = mysql_query($sqlhead2,$conn) ;
	 $head2 = Mysql_fetch_array($rs); 
	$rs = mysql_query($sqlmsg2,$conn) ;
	  $msg2 = Mysql_fetch_array($rs);
	  }
function callpagedataabout()
	{ $conn = mysql_connect("localhost","******","*******")
				or die("ERR:CONN");
	  $rs = mysql_select_db("pages",$conn)
	  			or die("ERR:DB");
	  $sqlhead1 = 'SELECT * FROM `about` WHERE `variable` like `head1` ';
	  $sqlmsg1 = 'SELECT * FROM `about` WHERE `variable` like `msg1`  ';
	  $sqlhead2 = 'SELECT * FROM `about` WHERE `variable` like `head2` ';
	  $sqlmsg2 = 'SELECT * FROM `about` WHERE `variable` like `msg2` ';
	  
		$rs = mysql_query($sqlhead1,$conn) ;
	  $head1 = Mysql_fetch_array($rs);
	$rs = mysql_query($sqlmsg1,$conn) ;
	  $msg1 = Mysql_fetch_array($rs);
	$rs = mysql_query($sqlhead2,$conn) ;
	 $head2 = Mysql_fetch_array($rs); 
	$rs = mysql_query($sqlmsg2,$conn) ;
	  $msg2 = Mysql_fetch_array($rs);
	}
function callpagedatacontact()
	{ $conn = mysql_connect("localhost","******","*******")
				or die("ERR:CONN");
	  $rs = mysql_select_db("pages",$conn)
	  			or die("ERR:DB");
	  $sqlhead1 = 'SELECT * FROM `contact` WHERE `variable` like `head1` ';
	  $sqlmsg1 = 'SELECT * FROM `contact` WHERE `variable` like `msg1`  ';
	  $sqlhead2 = 'SELECT * FROM `contact` WHERE `variable` like `head2` ';
	  $sqlmsg2 = 'SELECT * FROM `contact` WHERE `variable` like `msg2` ';
	
	 	$rs = mysql_query($sqlhead1,$conn) ;
	  $head1 = Mysql_fetch_array($rs);
	$rs = mysql_query($sqlmsg1,$conn) ;
	  $msg1 = Mysql_fetch_array($rs);
	$rs = mysql_query($sqlhead2,$conn) ;
	 $head2 = Mysql_fetch_array($rs); 
	$rs = mysql_query($sqlmsg2,$conn) ;
	  $msg2 = Mysql_fetch_array($rs);
	  }
#Testing to see if it works without include
	$page = $_GET['page'];
	detectpagecalled($page);
	Echo($head1);
	echo($head1['content']);

The test at the end was designed to see if the script works, the script is to be included into my index.php file Any help would be GREATLY appreciated, i bhave debugged etc. and everything is fine 'n' dandy so i am at a loss to see what is wrong.The content of my mysql table at the moment is as follows:
my column titles are:
COLUMNS->variable,content
and as records i have:
RECORD->head1,Testing head text
RECORD->msg1,testing msg text

#2 alpine

alpine
  • Members
  • PipPipPip
  • Advanced Member
  • 756 posts
  • LocationNorway

Posted 18 May 2006 - 09:52 PM

You don't tell anything about what your exact problem is (errormsg)
First off you need to quote
// if($page == home)
if($page == "home")
should get u one step further




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users