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
https://forums.phpfreaks.com/topic/72928-solved-derived-url-field/
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!

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.