How can this be done?

I was trying to figure out if I can do this and I need some direction…
I have www.mvsr.org and I’m trying to make the whole site dynamic (using PHP and storing all pages in a mysql database

This is what I have soo far.

CREATE TABLE Pages (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
Display TINYINT(1),
Name VARCHAR(20),
Content TEXT(1500)
);
I can store each page in this table and its up to the user if a page is even visible (like if they decide to not have a news center they can turn the display off and it wouldn’t show on the horizontal menu).

So I’m thinking this is what I have to do.
Create a template page to show those pages (page.php) which would be set up like this…


<html>
<?php

include ("secure/config.php");
include ("secure/opendb.php");
$Page = $_GET['ID'];
$query  = "SELECT Name, Content FROM Pages WHERE Name = '$Page'";
$result = mysql_query($query) or die('Error, query failed');
$row = mysql_fetch_array( $result );
?>
<head>
<title><?php echo $row['Name']; ?></title>
<link href="/css/main.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="wrapper">
        <div id="header">
<?php include("ssi/header.php"); ?>
        </div>
        <div id="content">
            <div id="content_top">
            <h1><?php echo $row['Name']; ?></h1> 
<?php echo $row['Content']; ?>
<?php include("ssi/footer.php"); ?>
               </div>
        </div>
        <div id="bottom">                 
        </div>
</div>
</body>
</html>

I think that this looks ok (that way all the links to all my pages would look like page.php?ID=About)

But how would I go about getting nothing but markup into Content?
Should I use http://www.openwebware.com/wysiwyg/demo.shtml
Also there is the problem of how I would make the active page “stand out” in the menu (right now I have it coded in my style sheet which page to make the “tab” appear to be in front). But have no idea how to achieve this effect when the pages are dynamic…
Any advice would be greatly appreciated.

Thanks

lots of questions here which are not mysql specific but anyway, here goes with as many as I can try to help with.

  1. don’t forget your doctype. (you may have omitted it for the example in your post).

  2. header.php? Maybe a name change coz to me, header should contain the head section of the page - doctype, title, head sections.

  3. or die(‘Error, query failed’);
    this might be bnetter if you use the ‘mysql_error’ syntax, so it’ll tell you exactly what the error is.

  4. there’s a bit of div confusion for me. do you need both content and content_top divs? and why is footer.php in content_top div and not in the mepty ‘bottom’ div?

  5. you can get the param ‘About’ or whatever from the query string and use it to match with the class for the menu tag, so as to apply a highlight css to it and make it stand out, for the respective page you are on. that’s a phph question btw.

  6. and as for ‘But how would I go about getting nothing but markup into Content?’ , I don’t quite understand. you had a post about this a day or two ago as well. The way I do it is to ahve the xhtml code in my script and the ‘variable’ content, as served up by the db queries inserted amongst it in the page.

The only xhtml content I would have in may db would be when a text block shows as part of it, a web link. That is achieved in your input form or cms system where it is inputted to the db column, along with the ordinary text for you page. again, thats more of a php question.

hth

bazz

here’s how I would adjust the html ooutput that you have shown.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<?php

include ("secure/config.php");
include ("secure/opendb.php");
$Page = $_GET['ID'];
$query  = "SELECT Name, Content FROM Pages WHERE Name = '$Page'";
$result = mysql_query($query) or die('Error, query failed');
$row = mysql_fetch_array( $result );
?>
<head>
<title><?php echo $row['Name']; ?></title>
<link href="/css/main.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="wrapper">
        <div id="header">
<?php include("ssi/header.php"); ?>
        </div>
        <div id="content">
            <h1><?php echo $row['Name']; ?></h1> 
<?php echo $row['Content']; ?>
        </div>               
        <div id="bottom">
    <?php include("ssi/footer.php"); ?>             
        </div>
</div>
</body>
</html>

I mentioned in the earlier thread about start dates and end dates, instead of the boolean value for the display column.

It may not apply to your project but, the reason for this is; imagine someone wants to change a page next week, but they will be away on leave. using the dates method, they can make the change today and it won’t become live util the start date they assign. Otherwise, they either have made a page live to soon, or, they have an old page still running after they would have liked to have a new one. This method gives greater flexibility to the user, perhaps for another project you may undertake.

hth

bazz

jeez, your all over the place ibazz.
Thanks

I didn’t think about that as a use of that date thing but that sounds like a great feature, but do you mind if I steal it?

Instead of this
$result = mysql_queryCOLOR=#66CC66[/COLOR] or die(‘Error, query failed’);


$result = mysql_query[COLOR=#66CC66]([/COLOR]$query[COLOR=#66CC66])[/COLOR] or die[COLOR=#66CC66]([/COLOR][COLOR=#CC0000]'Error, query failed'[/COLOR][COLOR=#66CC66])[/COLOR];

I doubt there is anything proprietary in my ‘dates’ suggestion but I appreciate very much, that you asked.

I can now understand a reason for using the boolean in the table as well. sort of an instant on/off.

I don’t do php but the error syntax is something along the lines of


$result = mysql_query($query) or die(mysql_error); 

Haven’t seen it in anyone’s post for a few weeks so I may be wrong. just ask in the php forum. and post back here as more mysql questions arise.

bazz

I didn’t think about that as a use of that date thing but that sounds like a great feature, but do you mind if I steal it?

  1. I like your doctype, mind if I steal that too?
    2.Yup, I change the name to menu.ssi or something more relevant.
    3.Instead of this

$result = mysql_query($query) or die('Error, query failed');

I can use


 $result = mysql_query($query) or die(mysql_error());
 

To get the error, rather than my bland message.
4. I thought this way was ok, but let me know if I’m wrong…
The content-top div has that background with the shadow to make it look like a page coming down. then the content div has another background to make it look like the page extends, (that’s why I have a div inside another div
is there a way I can use 1 div and achieve the same effect?)
5. Sorry, but I’m sort of dumb, can you expand on this please?
6. Your way makes more sense rather than storing my code, but what about if some idiot wants to center or align the text (or change colors, bold, or underline, add pictures. Basically they want to customize it )

ok,

  1. I’ll have to check that out tomorrow coz it’s 3.30am here and I am becoming superficial in my level of concentration.

  2. this is a php issiue. did I say I don’t do php? I do perl. OK, so in php, there is a way to get the query string - that bit of stuff that is added to the url of the page/file from ? onwards.

so if the value of a part of that string is About, and you hold it in a php variable, you can run a small section of php, to match it with the class of the menu button.

pseudo code:


if ($var eq 'About'){
  print qq(
  <li><a class='About' href='#'>about</a></li>
  );
}
else {
print qq(
  <li><a href='#'>About</a></li>
  );
}

  1. everything but the images should be in the css file which you can allow them to edit in a small content management system - perhaps, of your own.

Basically provide a login area, where they can click ‘edit css’. the resultant page would have queried the db or text file, for the css data and presented it in a textarea on the web page as part of a form. Having edited it, they can submit the form and the css is stored anew.

As for images and others managing them, you’ll need to have an imaging section in your login. upload images, put them into a gallery and remove images, remove galleries and remove images from a continuing gallery.
(thats what I do for an image gallery).

for images in the text of the page, I do that in my input text form, by having a <select> for each image I need to upload.

Y’know, it might be easier for you, (with abit of a learning curve), if you were to use wordpress or something - an ‘off-the-shelf’ content management solution. But there’s no reason you can;t build your own. I did it for my own projects. (well when I say I did it, I got a heck of a lot of MySQL help here and perl help in another forum).

bazz

OK, I have gone over your current page using tables and it looks to me like the content div has the shadowed edge to the right-hand side - and it runs from the horizontal nav menu to the bottom of the page. I see nothing visual about the content_top div so (unless I am missing something), I would remove it.

I would also put each of the box sections (currently tables) into their own divs and float them as necessary if you want them to appear as they do now.

And another point: the <p></p> tags containing the two links beneath the word ‘Home’, should be in a UL list. no need for all those   on the page.
needless clutter.

hth

bazz

interesting direction this “mysql” thread has taken…

:cool: