Im a part of an online game community and we have an HTML table listing all of the staff in said community. When staff leave or their sections change, it becomes a hassle to edit the table. Since Im a programming student in CIS115 (PHP/XHTML), I figured I would attempt to make a webpage in PHP to edit and change these sections.
However, I do not know where to begin. I was thinking of something involving data stored in text files for each member of staff, specifically a URL associated with their name. Then I need the program to search through the HTML table code and replace the staff members name and their URL with the new one. Obviously this has to be user friendly, so some sort of HTML inputs would be necessary.
Could I get a push in the right direction?
Dynamically changing text within a page.
Moderator: General Moderators
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: Dynamically changing text within a page.
Welcome to DevNetwork and thanks for posting intelligently. 
You'll want to start working with databases, namely MySQL. I recommend downloading XAMPP so you can setup a server on your computer and test things out locally first.
Then you'll want to mess around with phpMyAdmin to get up to speed with MySQL. It's not perfect but it's a decent place to start.
XHTML...
<input name="post_example" />
PHP
$something = $_POST['post_example'];
Security is also a concern to you'll need to modify the above code...
Secured PHP
$something = mysql_real_escape_string($_POST['post_example']);
Now we can put this in to a database.
If you're running XAMPP for XP the URL should be...
http://localhost/phpmyadmin/
You'll first need to create a table.
A table has columns (like a pillar) and rows (like steps). You'll need to create an auto-increment column which means it's unique.
Give your names meaningful names with prefixes (blog_post, blog_date, blog_comment) as this will make future development much easier to deal with.
There are different types of data, INT for integers (numbers) so that would be good for your auto-increment id (INT(7) would support up to 9,999,999 instances in example). There is data/time which uses a sort of universal format.
Any way it's a little rough when you first get going but php.net is an awesome source of examples of PHP code and it'll also have suggestions for related already built-in functions in PHP.
As far as building a specific PHP/MySQL script you'll have to learn how to use the essential aspects of the languages though once you're on your way you'll be able to do just that and more. Good luck.
You'll want to start working with databases, namely MySQL. I recommend downloading XAMPP so you can setup a server on your computer and test things out locally first.
Then you'll want to mess around with phpMyAdmin to get up to speed with MySQL. It's not perfect but it's a decent place to start.
XHTML...
<input name="post_example" />
PHP
$something = $_POST['post_example'];
Security is also a concern to you'll need to modify the above code...
Secured PHP
$something = mysql_real_escape_string($_POST['post_example']);
Now we can put this in to a database.
If you're running XAMPP for XP the URL should be...
http://localhost/phpmyadmin/
You'll first need to create a table.
A table has columns (like a pillar) and rows (like steps). You'll need to create an auto-increment column which means it's unique.
Give your names meaningful names with prefixes (blog_post, blog_date, blog_comment) as this will make future development much easier to deal with.
There are different types of data, INT for integers (numbers) so that would be good for your auto-increment id (INT(7) would support up to 9,999,999 instances in example). There is data/time which uses a sort of universal format.
Any way it's a little rough when you first get going but php.net is an awesome source of examples of PHP code and it'll also have suggestions for related already built-in functions in PHP.
As far as building a specific PHP/MySQL script you'll have to learn how to use the essential aspects of the languages though once you're on your way you'll be able to do just that and more. Good luck.
Re: Dynamically changing text within a page.
Thank you for your post, JAB Creations. I appreciate your generosity but I already know how to do most of that.
I'll check into SQL tables, even though I hate messing with them at this point. Creating database arrays was the last thing I wanted to do but looks like I'll have to.
I'll check into SQL tables, even though I hate messing with them at this point. Creating database arrays was the last thing I wanted to do but looks like I'll have to.
Re: Dynamically changing text within a page.
I, too, would recommend using MySQL rather than text files, although that's also possible. What you need to do is generate the HTML table with PHP each time the web page is requested. You don't need to search and replace anything, just use the URLs and names as they are represented in the database at the moment the web page is requested. So you need the database, a table in the database to hold the staff names and URLs, a method of updating the database (either use a control panel like phpMyAdmin or write your own simple PHP scripts (it's not very hard)), and generate your page with PHP.Sunsparc wrote:Im a part of an online game community and we have an HTML table listing all of the staff in said community. When staff leave or their sections change, it becomes a hassle to edit the table. Since Im a programming student in CIS115 (PHP/XHTML), I figured I would attempt to make a webpage in PHP to edit and change these sections.
However, I do not know where to begin. I was thinking of something involving data stored in text files for each member of staff, specifically a URL associated with their name. Then I need the program to search through the HTML table code and replace the staff members name and their URL with the new one. Obviously this has to be user friendly, so some sort of HTML inputs would be necessary.
Could I get a push in the right direction?
If you get the general idea, we'll be glad to try to help with specific questions or problems as you go along.