Styles2304 Posted July 12, 2007 Share Posted July 12, 2007 I'm working on an update method for my Church's website and I was wanting to do something where certain individuals could login to a "control panel" and be able to add certain information such as events or a little blurb about something. I already have the login and control panel the way I want them and I'm guessing for them to be able add "events" (paragraphs of information) to a list, I would need to append a document with an array of the information they fill out on the form. My real problem is that I don't know how to actually process the entered information on the page itself. I know it should probably be like foreach array do this . . . but I'm not quite sure how to go about telling php to spit out html so that the page looks presentable. Does that make sense? If I'm not clear at all, please, just say something and I'll try to say it again as clearly as possible. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 12, 2007 Share Posted July 12, 2007 Yes, but doing this flatfile (as you are suggesting with appending a document) is like jabbing yourself with a rusty knife, instead look into mysql which is very good for events. (Let me know if you need help I have an event script I can share with you, but you have to understand mysql/php to use it.) Quote Link to comment Share on other sites More sharing options...
Styles2304 Posted July 12, 2007 Author Share Posted July 12, 2007 :: sigh :: I was hoping to NOT hear that . . . I'll probably be back in a week or so once I've learned a little mysql. Thanks for the help. Quote Link to comment Share on other sites More sharing options...
Styles2304 Posted July 12, 2007 Author Share Posted July 12, 2007 Hmm actually, would you be able to give me an idea of the direction I should go with this stuff? Should I be learning how to store data in a database . . . or retrieve data . . . or what am I actually going to be using to accomplish this? Quote Link to comment Share on other sites More sharing options...
per1os Posted July 12, 2007 Share Posted July 12, 2007 You will need to learn how to store data properly, retrieve data and how to build a table structure. MySQL is quite a bit different and sometimes hard for people to grasp the concept. Your main focus will be on SELECT statements, INSERT statements and UPDATE statements. You will also need to look into PHP While loops for retrieving data along with arrays. Along with mysql_connect; mysql_query; mysql_fetch_array; via PHP.net. But the key is to keep everything in Third Normal Form (3NF) google will have a bunch of articles/pages on that. Table structure and setup is important to keep a site running fast, clean and efficient. On another note it can be done with files, like stated above it is a pain in the ass to work with them because you have to open read them parse them append them and re-write them all in while that is happening no one else can work with that file. Which is why MySQL is preferred. Especially given that it is 1,000x faster than a file database could ever be, with searching sorting selecting etc. Quote Link to comment Share on other sites More sharing options...
Styles2304 Posted July 20, 2007 Author Share Posted July 20, 2007 Ok! So I've learned some php . . . enough to actually create/modify/maintain a database as well as how to do that through php. The only thing I'm confused on now is how to setup the loop statement so that for every block of information, it spits it out in a table. Basically, I'm not quite sure how to get the MySQL data into an array. Can someone give me an example? Also! Can you explain it line by line just so I know we're on the same page. If not, no worries, I should be able to figure it out. Quote Link to comment Share on other sites More sharing options...
Styles2304 Posted July 28, 2007 Author Share Posted July 28, 2007 bump Quote Link to comment Share on other sites More sharing options...
MemphiS Posted July 28, 2007 Share Posted July 28, 2007 <?php $sql = mysql_query("SELECT `column` FROM `table` ORDER BY `id`"); while ($getSQL = mysql_fetch_row($sql)){ echo "Output: $getSQL[0]"; } ?> Quote Link to comment Share on other sites More sharing options...
mdnghtblue Posted July 28, 2007 Share Posted July 28, 2007 Very simply: $my_query = mysql_query("SELECT * FROM churchinfo;"); while($info = mysql_fetch_array($my_query)) { print "$info[name]<br>"; print "$info[email]<br>"; print "$info[age]<br><br>"; } The first line sends a query to the database, to select all info from a table called "churchinfo". This is stored in $my_query. Right now, $my_query is kind of like a two-dimensional array, holding rows of arrays with your information. To get the information for each row, use a while loop and mysql_fetch_array(); So if your database table is something like this: Name Email Age John john@blah.com 24 Mary mary@blah.com 35 Bob bob@blah.com 27 Your output from the while loop will look like this: John john@blah.com 24 Mary mary@blah.com 35 Bob bob@blah.com 27 Hope that explains something. >.< Someone out there can probably do a better job. Quote Link to comment Share on other sites More sharing options...
Styles2304 Posted July 30, 2007 Author Share Posted July 30, 2007 Ok, well that certainly makes sense . . . However, I'm wanting to spit out each chunk of information in it's own table . . . so can I just throw in the standard html for tables in the while statement? Also, I thought you had to use a for statment and $i to do a loop or something. Is that not right? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.