Jump to content

[SOLVED] Derived URL Field


eightFX

Recommended Posts

Hey everyone,

 

Looking for a little help, not sure how to do what I am trying to do, or if it is even possible, but figured I would ask anyhow.

 

What I am trying to do is derive a url from another field in the table. For example:

 

Table: pages

Table Fields: ID | TITLE | CONTENT | URL

 

ID is auto-incremented. TITLE is inputted. CONTENT is inputted. URL is http://myurl.com/?page=ID (ID being the auto incremented field)

 

I think I could use an update after adding the data initially to create it, but I was hoping there was a better way to do it.

 

$query = INSERT INTO pages (ID, TITLE, CONTENT, URL)

VALUES (0, 'This is my title', 'This is my content', 0)

 

then do a SELECT query choosing the ID and TITLE to get the ID, then do a UPDATE query on URL field to include http://myurl.com/?page=$row[iD].

 

Not sure if any of this makes sense which could be why I am having trouble trying to think it through.

 

 

Thanks for any help!

 

Link to comment
Share on other sites

So in php just refer to the id instead. such as..    href=http://myurl.com/page='.$row[id].' ... etc

 

I have done what I wrote above before, thought it might be easier to store it all in the database, oh well. Sounds good, thanks Fenway!

 

P.S. Go Red Sox! Game 1 of ALCS! Hoorah!

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.