Jump to content

Making a DB autofill a column with a "topic"


0o0o0

Recommended Posts

Two questions..

 

I have two tables.. one plumbing, one flooring.

To see the list on a browser I created php and html.. all good. one for plumbing one for flooring.

 

now today I want to COMBINE the two on one page.. so I did...

 

but to the viewer they see a list and cannot tell whether a line is plumbing or flooring unless they read the details.

 

I would like the ending to state PLUMBING, or to state FLOORING.. for quick reference.

 

So the two questions..

 

how does one make a column in their table lets call it "Jobtype" to always add the word "PLUMBING "  when an entry is inputted.. ( kind of like how timestamp stamps the time without any manual input)

 

 

second question maybe easier than messing with my tables.

 

If you had such setup like ive explained how would you php program to post PLUMBING if the line came from plumbing table, and post FLOORING  if the next 2 lines were from flooring, and the next 4 lines say ( any number ) to post PLUMBING ...  other than simply having $jobtype, if the tables werent done like question one.

 

todays been pretty hazy so I came to the forums for a little brain wake up ;) 


 

Link to comment
Share on other sites

Lets do this another way.. 

 

say you have 3 identically structured tables.. except ones for plumbing, ones for electrical ones for say carpentry

 

now eventually you want to create another table called.  ALL

 

So you would dump table 1 (plumbing)  table 2 (electrical) table 3 (carpentry) into ALL... by cron at the end of everyday in the future..

 

You would have a table with all the tables info, except no real understanding of which row is plumbing, electrical or carpentry.

So .. what i trying to find on the net, which I havent found yet.. is every time I put an entry into plumbing.. i do the usual.. but is there a

way to create something like what TIMESTAMP row does.. but its just the word "PLUMBING"   automatically in a row.. when I hit save.  In that table forever..

 

same for adding an entry into electrical, the last row ( I will add to all tables when I find out if this is capable) the last row will automatically enter ELECTRICAL.

 

get me?  I know I sound LAAAAAZY.. lol but eventually adding the word "plumbing" to the last row in plumbing table every single time.. tedious.

So.. now down the road, I dump all 3 tables into ALL table.. and I can then grab all plumbing when needed or all electrical, or plumbing and electrical without carpentry etc etc..

 

Or am im outdated? and theres a way to dump tables and insert which table they came from in the process of dumping the three tables into the "ALL" table.

 

( im not using "ALL" as a table name, its just for explanation here)

 

 

Even if I wanted to just spit out the entire all 3 databases on an webpage as it stands now.... they COULD  say plumbing , electrical, carpentry  on them.. but it still wouldnt have it in the last row in the tables.

Edited by 0o0o0
Link to comment
Share on other sites

first of all, you are asking about a value in a column, not a row.

 

 

how does one make a column in their table lets call it "Jobtype" to always add the word "PLUMBING "  when an entry is inputted..

 

 

the answer is to add some programming logic to the code that's INSERTing the data. they call this stuff software for a reason. if it doesn't do what you want, you can change it to suit your needs. you should actually have a jobtype table that defines the different jobtype names and assigns a jobtype_id to each one. it's the jobtype_id that should be stored in the jobtype column.

 

you should not be regularly dumping this data into a combined database table. you should do this once for the existing data, then use the single combined database table from that point forward.

Link to comment
Share on other sites

Lets do this another way.. 

 

say you have 3 identically structured tables.. except ones for plumbing, ones for electrical ones for say carpentry

 

now eventually you want to create another table called.  ALL

 

So you would dump table 1 (plumbing)  table 2 (electrical) table 3 (carpentry) into ALL... by cron at the end of everyday in the future..

 

**NO I Wouldn't, not at the end of the day, not to the same server, not ever.**

 

You would have a table with all the tables info, except no real understanding of which row is plumbing, electrical or carpentry.

 

**That's in complete contradiction to the operating paradigm of a relational database system**

 

So .. what i trying to find on the net, which I havent found yet.. is every time I put an entry into plumbing.. i do the usual.. but is there a

way to create something like what TIMESTAMP row does.. but its just the word "PLUMBING"   automatically in a row.. when I hit save.  In that table forever..

 

same for adding an entry into electrical, the last row ( I will add to all tables when I find out if this is capable) the last row will automatically enter ELECTRICAL.

 

get me?  I know I sound LAAAAAZY.. lol but eventually adding the word "plumbing" to the last row in plumbing table every single time.. tedious.

 

So.. now down the road, I dump all 3 tables into ALL table.. and I can then grab all plumbing when needed or all electrical, or plumbing and electrical without carpentry etc etc..

 

Or am im outdated? and theres a way to dump tables and insert which table they came from in the process of dumping the three tables into the "ALL" table.

 

( im not using "ALL" as a table name, its just for explanation here)

 

 

Even if I wanted to just spit out the entire all 3 databases on an webpage as it stands now.... they COULD  say plumbing , electrical, carpentry  on them.. but it still wouldnt have it in the last row in the tables.

 

You're coming at this all wrong.  The scenario you described is fundamentally the wrong thing to do.  Why don't you give us the information relating to what you're actually look to accomplish with this and maybe we can give you a better solution.

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.