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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.