Jump to content

Reading and Writing to Database (Should be simple)


Clarkie

Recommended Posts

Hey,

 

I'm trying to work out how I can have a simple script that will work like this:

 

Page 1 - Heading, Paragraph, Image read from database.

Page 2 - Has text boxes allowing you to change heading, paragraph and image (url) with each edit using a different text box. (Admin panel)

 

The database connection would be in a separate file.

 

So far I've got the database connection sorted.

 

<?php
//Database Information
$dbtype = "mysql"; 
$db_host = "localhost";
$db_user = "";
$db_pass = "";
$db_name = "";
$db_port = "";
$db_table_prefix = "userCake_";
?>

 

At the top of each of the other pages this is what I've got.

<?php 
require_once("models/config.php");
?>

 

Let's say I give each bit stored in the database a page ID and an object ID.

 

If the page selected is index.php how can we give it a page ID of 1 and give then include all the separate 'objects' throughout the page?

 

Hopefully this makes sense?

 

Cheers,

Jack

Sounds like you need one script to display the page which shows the heading, image and paragraph. Have the script accept a pageID in the querystring ($_GET).

 

Then a separate page for the admin, which again takes a pageID and populates the textboxes ready to edit.

 

Use the $_GET['pageID'] to select the record from the database.

 

What about a table in the db with fields: id, heading, image, paragraph.

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.