NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Please help me with PHP!

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search
4 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 05-08-2006, 05:16 AM THREAD STARTER               #1 (permalink)
NamePros Regular
Join Date: Mar 2006
Posts: 491
cesarian has a spectacular aura aboutcesarian has a spectacular aura about
 


Save a Life Child Abuse Animal Rescue AIDS/HIV

Please help me with PHP!


Hi, I need some help with php. I have a file index.html. I want to replace the links of the index.html, so I write:
Code:
<body>
%menu%
</body>
Then I have menu_template.txt:
Code:
<table id="AutoNumber1" style="border-collapse: collapse; font-family: Verdana; font-size: 11px; text-decoration: none" borderColor="#111111" cellSpacing="0" cellPadding="3" width="100%" border="0"><tr><td width="19"><img src="http://mysite.com/images/bullet.jpg"></td><td width="1061"><a style="font-family: Verdana; font-size: 11px; text-decoration: none" href="http://mysite.com/folders/">%text_menu%</a></td></tr></table>
I also have terms.txt:
Code:
A
B
C
I want to replace %menu% in index.html file with text in menu_template.txt. In menu_template.txt I want to multiple the text and replace %text_menu% with the terms from terms.txt.
????: NamePros.com http://www.namepros.com/programming/195133-please-help-me-with-php.html

The output will be like this:
Code:
<body>
<table id="AutoNumber1" style="border-collapse: collapse; font-family: Verdana; font-size: 11px; text-decoration: none" borderColor="#111111" cellSpacing="0" cellPadding="3" width="100%" border="0"><tr><td width="19"><img src="http://mysite.com/images/bullet.jpg"></td><td width="1061"><a style="font-family: Verdana; font-size: 11px; text-decoration: none" href="http://mysite.com/folders/">A</a></td></tr></table>
<table id="AutoNumber1" style="border-collapse: collapse; font-family: Verdana; font-size: 11px; text-decoration: none" borderColor="#111111" cellSpacing="0" cellPadding="3" width="100%" border="0"><tr><td width="19"><img src="http://mysite.com/images/bullet.jpg"></td><td width="1061"><a style="font-family: Verdana; font-size: 11px; text-decoration: none" href="http://mysite.com/folders/">B</a></td></tr></table>
<table id="AutoNumber1" style="border-collapse: collapse; font-family: Verdana; font-size: 11px; text-decoration: none" borderColor="#111111" cellSpacing="0" cellPadding="3" width="100%" border="0"><tr><td width="19"><img src="http://mysite.com/images/bullet.jpg"></td><td width="1061"><a style="font-family: Verdana; font-size: 11px; text-decoration: none" href="http://mysite.com/folders/">C</a></td></tr></table></body>
Would someone please help me? Please PM me or replay this post. Thank you.
cesarian is offline  
Old 05-08-2006, 05:29 AM   #2 (permalink)
 
BillyConnite's Avatar
Join Date: Jul 2005
Location: Coffs H, Australia
Posts: 3,456
BillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond repute
 


Wildlife Parkinson's Disease Parkinson's Disease
I think I know what you mean, and this is the code you'll need to do it : http://www.namepros.com/code/189417-...-php4-5-a.html

Let us know if you need any extra help with that!

Best of luck cesarian,
Rhett.
BillyConnite is offline  
Old 05-08-2006, 07:14 AM   #3 (permalink)
NamePros Member
Join Date: Apr 2005
Posts: 117
mikesherov will become famous soon enoughmikesherov will become famous soon enough
 



PHP Code:
<?php
$page_template
=file_get_contents("index.html");
????: NamePros.com http://www.namepros.com/showthread.php?t=195133
$row_template=file_get_contents("menu_template.txt");
$term_array=file("terms.txt"); //forgot a quote, thanks jim

foreach($term_array as $term){
     
$rows.=str_replace("%text_menu%",$term,$row_template);
}

echo 
str_replace("%menu%",$rows,$page_template);

?>
This should work. I haven't tested it, and just wrote it now into this textbox, but it should work. If you need an explanation of why or how it works, PM me.
Last edited by mikesherov; 05-08-2006 at 08:20 AM. Reason: forgot a quote, thanks jim
mikesherov is offline  
Old 05-08-2006, 08:12 AM   #4 (permalink)
NamePros Regular
 
Jim_'s Avatar
Join Date: Aug 2005
Location: NY, USA
Posts: 608
Jim_ is a splendid one to beholdJim_ is a splendid one to beholdJim_ is a splendid one to beholdJim_ is a splendid one to beholdJim_ is a splendid one to beholdJim_ is a splendid one to behold
 


Save The Children
PHP Code:
$term_array=file("terms.txt"); 
????: NamePros.com http://www.namepros.com/showthread.php?t=195133
You forgot a quote
__________________
ask me about the internet
Jim_ is offline  
Old 05-09-2006, 01:40 AM THREAD STARTER               #5 (permalink)
NamePros Regular
Join Date: Mar 2006
Posts: 491
cesarian has a spectacular aura aboutcesarian has a spectacular aura about
 


Save a Life Child Abuse Animal Rescue AIDS/HIV
Thank you for the code but I do not really understand the first code(I am a beginner) and the second code did not work.

The problem is that I want to replace %menu% but it won't replace it and what I need now is not only to replace %text menu% but also the url folders. So I have now also folders.txt.

The script must then count the line in terms.txt and multiple the line in menu_template.txt and replace %text_menu% and %folders%.

Output example:
Code:
<body>
<table id="AutoNumber1" style="border-collapse: collapse; font-family: Verdana; font-size: 11px; text-decoration: none" borderColor="#111111" cellSpacing="0" cellPadding="3" width="100%" border="0"><tr><td width="19"><img src="http://mysite.com/images/bullet.jpg"></td><td width="1061"><a style="font-family: Verdana; font-size: 11px; text-decoration: none" href="http://mysite.com/hallo/">A</a></td></tr></table>
<table id="AutoNumber1" style="border-collapse: collapse; font-family: Verdana; font-size: 11px; text-decoration: none" borderColor="#111111" cellSpacing="0" cellPadding="3" width="100%" border="0"><tr><td width="19"><img src="http://mysite.com/images/bullet.jpg"></td><td width="1061"><a style="font-family: Verdana; font-size: 11px; text-decoration: none" href="http://mysite.com/my/">B</a></td></tr></table>
<table id="AutoNumber1" style="border-collapse: collapse; font-family: Verdana; font-size: 11px; text-decoration: none" borderColor="#111111" cellSpacing="0" cellPadding="3" width="100%" border="0"><tr><td width="19"><img src="http://mysite.com/images/bullet.jpg"></td><td width="1061"><a style="font-family: Verdana; font-size: 11px; text-decoration: none" href="http://mysite.com/world/">C</a></td></tr></table></body>
You will see that the %text menu% is now A, B and C and the folders are Hallo, My and World. Please help me.
????: NamePros.com http://www.namepros.com/showthread.php?t=195133

Thank you
cesarian is offline  
Closed Thread


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


 
All times are GMT -7. The time now is 02:13 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger