Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 13th, 2005, 4:51 PM   #1
dmorales
Programmer
 
Join Date: Feb 2005
Posts: 74
Rep Power: 4 dmorales is on a distinguished road
what's the best way to do this?

I have one page where you a user can enter into fields items they would like to display as bulletins. Then I want them to display on the index page. I'm not sure which is going to be the best way of doing it? Can you point me in the right direction?

Just a hint would be ok. I still want to write it myself. So at least I get some good practice there.
__________________
Lorem ipsum dolor sit amet...
dmorales is offline   Reply With Quote
Old Apr 13th, 2005, 4:54 PM   #2
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
use a database or a text file.

the database route is far supreme though.

check out a db system like mysql or postgresql. that should get you started in the right direction.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Apr 13th, 2005, 5:06 PM   #3
dmorales
Programmer
 
Join Date: Feb 2005
Posts: 74
Rep Power: 4 dmorales is on a distinguished road
at first I was going to do that, insert into a table and then formt he index page query and echo the tables contents, but I don't want it to keep adding I only want 10 bulletins to appear and for those to be edited by the same screen that input them.

Maybe i'm gong about it the wrong way.

I also thought if I could insert each of the fields into an array that and then print them on the index page. Will this work? and if so How do I call the array from the index page?
__________________
Lorem ipsum dolor sit amet...
dmorales is offline   Reply With Quote
Old Apr 13th, 2005, 7:02 PM   #4
BlazingWolf
Hobbyist Programmer
 
Join Date: Sep 2004
Posts: 207
Rep Power: 4 BlazingWolf is on a distinguished road
You can limit to the number of results from the table by putting LIMIT 10 in your SQL query.

ex. SELECT * FROM 'my_table' LIMIT 10

(Someone correct me if that is wrong.)

You can ensure that they are newest 10 by having a date field and modifiing the clause to get only the newest 10.
__________________
_______________________________
BlazingWolf
BlazingWolf is offline   Reply With Quote
Old Apr 13th, 2005, 9:16 PM   #5
ice52
Newbie
 
Join Date: Apr 2005
Posts: 9
Rep Power: 0 ice52 is on a distinguished road
It depends, you haven't really given enough information about what you want to do...

If you want this information to be availiable to anyone who visits the index page then yes you will need to store it somewhere. But if its only 10 things then I dont think the trouble of setting up an MySQL database and querying it is really worth it.. I dont normally use text files for anything big but for something of that scale it is far more appropriate.

Another possiblilty is storing them in server memory as global variables but *cough* I didnt make that suggestion because global varibles are evil and unsafe.

If you only wanted to temporarily display them for the user that posted them you wouldnt even need to store them, you would just need to output them (why even bother loading them into an array when they have to get sent seperately by the form) you could output them straight from the temporary variables (i.e $_POST[]) straight to the page.
__________________
www.ice52.co.uk
ice52 is offline   Reply With Quote
Old Apr 13th, 2005, 9:32 PM   #6
dmorales
Programmer
 
Join Date: Feb 2005
Posts: 74
Rep Power: 4 dmorales is on a distinguished road
Thanks for your advice everyone. Here's some more information that might be helpful.

It's for a database I'm making.

It's got to be permanet until changed by a user.

The Home page of the database will have a section where bulletins can be posted for other employees to see.

I have made one page where you can edit the bulletins list. via 10 different textboxes.

I want the to be able to go back to this page and edit/update these from the same page.

So what do you think? What will I need to do this?
__________________
Lorem ipsum dolor sit amet...
dmorales is offline   Reply With Quote
Old Apr 13th, 2005, 9:45 PM   #7
ice52
Newbie
 
Join Date: Apr 2005
Posts: 9
Rep Power: 0 ice52 is on a distinguished road
Yep, sounds like a database job to me.

You just need to make a table in the database to store all the info about the bulletins (id, message, poster?), MySQL is a favourite for databases you will need that as well as php (obviously). Then check out the MySQL functions on the php website, it should be pretty obvious what to do with those.

So you post the information to a page (possibly the index page) then you include a php function in this page to insert this info into the database, and another to query the database when the page is loaded up.

have I missed anything?
__________________
www.ice52.co.uk
ice52 is offline   Reply With Quote
Old Apr 13th, 2005, 9:53 PM   #8
dmorales
Programmer
 
Join Date: Feb 2005
Posts: 74
Rep Power: 4 dmorales is on a distinguished road
That's about right.

So I limit he table to 10.

inserting the information into the table.

then query the info back out.

Pretty simple except how will I edit them? (from the page I inserted them from, which is a separate page from the index page)
__________________
Lorem ipsum dolor sit amet...
dmorales is offline   Reply With Quote
Old Apr 13th, 2005, 10:11 PM   #9
ice52
Newbie
 
Join Date: Apr 2005
Posts: 9
Rep Power: 0 ice52 is on a distinguished road
ahh, well there you have to use the SQL command 'UPDATE', thats where the id comes in, you will need some way of getting the id to the page and being able to submit it back to the server, to show which one you want to edit. Since the id is unique it makes the record easy to identify and change.

The way I usually do it is via a link with a query string (eg href="myeditpage.php?id=2") but in this case you might want to send the edited info along with the id, so i suggest a form with a hidden input... I dont know...

do you want to be able to edit using the original as a template, because in that case you would need a textarea or something for every submission (so 10 then ) and each would probably need to be a seperate form with its own submit button... Thats just an idea though.

Hope I wasnt too confusing but yeah you are right about the steps...

except you might want to run a query on the DB when you add a new record that deletes any records after the 10th (you dont want those extra bulletins clogging up your db... unless you wanted to archive them of course)
__________________
www.ice52.co.uk
ice52 is offline   Reply With Quote
Old Apr 13th, 2005, 10:21 PM   #10
dmorales
Programmer
 
Join Date: Feb 2005
Posts: 74
Rep Power: 4 dmorales is on a distinguished road
I appreciate your help. I guess I'll just start working through it and see how it goes.

Maybe I'll save that part of the DB for last.
__________________
Lorem ipsum dolor sit amet...
dmorales is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:02 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC