Jump to content

Recommended Posts

I've looked around for something similar to this, but I couldn’t find anything. I have a script that allows users to post various information (comments, name etc.) to a MYSQL database. Each post is assigned a unique id when it is entered into the database.

 

What I am trying to do now is retrieve that data and give each post its own unique url (For example, one post could have the url http://www.example.com/showresults.php?id=3943). If one was to go to that link, they would see a specific post and that url would be unique to that post. I understand that you have to use variables but I don’t quite get how I would go about doing this. Any help would be greatly appreciated.

 

INSERT INTO content VALUES (1, 'http://localhost/index.php?p=ABOUTS');
INSERT INTO content VALUES (2, 'http://localhost/index.php?p=CONTACTS');

SELECT * FROM content WHERE href = 'http://localhost/index.php?p=ABOUTS'

 

You are probably trying to create a content management system where you work with 'pages', right?

<?php
if (empty($_GET['id'])) {
    //?id= does not exist, what to do?
}

$id = (int) $_GET['id'];
$query = 'SELECT * FROM contents WHERE id = %u';
$fquery = sprintf($query, $id);
$result = mysql_query($fquery, $db);
$row = mysql_fetch_assoc($result);
//work with $row
print $row['title'];
print $row['excerpt'];
?>

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.