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

Link to comment
Share on other sites

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.

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.