Jump to content

Mysql content selector help.


zbrahead

Recommended Posts

[code=php:0]<?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']);[/code]

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
Link to comment
https://forums.phpfreaks.com/topic/9954-mysql-content-selector-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.