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 with me with php!

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

Advanced Search


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


Save a Life Child Abuse Animal Rescue AIDS/HIV

Please help with me with php!


Hi, I need some help with php.

I want to replace multiple text with text from a folder.

content that I need to replace:
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://%site_url%/images/bullet.jpg"></td><td width="1061"><a style="font-family: Verdana; font-size: 11px; text-decoration: none" href="http://%site_url%/%site_folders%/">60 Minute Money
</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://%site_url%/images/bullet.jpg"></td><td width="1061"><a style="font-family: Verdana; font-size: 11px; text-decoration: none" href="http://%site_url%/%site_folders%/">7 Eleven Franchise
</a></td></tr></table>
You will see there %site_folders%.I need to replace %site_folders%.
????: NamePros.com http://www.namepros.com/programming/195831-please-help-with-me-with-php.html

content of folders.txt:
Code:
A
B
The output will be then:
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://%site_url%/images/bullet.jpg"></td><td width="1061"><a style="font-family: Verdana; font-size: 11px; text-decoration: none" href="http://%site_url%/A/">60 Minute Money
</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://%site_url%/images/bullet.jpg"></td><td width="1061"><a style="font-family: Verdana; font-size: 11px; text-decoration: none" href="http://%site_url%/B/">7 Eleven Franchise
</a></td></tr></table>
There are about more than 200 text that I need to replace please help me.

Thank you
cesarian is offline  
Old 05-10-2006, 09:37 AM   #2 (permalink)
Senior Member
 
Xyzer's Avatar
Join Date: Aug 2005
Location: United Kindom
Posts: 1,502
Xyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to all
 


Tsunami Relief AIDS/HIV
I dont understand what you mean. I would help if i did!
Xyzer is offline  
Old 05-10-2006, 10:21 AM   #3 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,069
Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute
 


Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
your best bet would be to convert to using a template engine instead of tryin to write 1 yourself as effectively that is what you are doing.

Also in your example there is no logical way to know which entry in folders.txt should be replacing which line in your original html.
__________________
Manage your portfolio using my new Domain Portfolio Management script.
Securing Your Domain Name From Theft
Peter is offline  
Old 05-10-2006, 03:16 PM   #4 (permalink)
NamePros Member
Join Date: Mar 2006
Location: (US) Missouri
Posts: 70
Hobnob is on a distinguished road
 



Im not quite sure what you are talking about either, but I will give you a solution to using multiple lines, I hope it helps...

You can use a here doc to achieve the following:

PHP Code:
<?php
$text 
= <<< END
<h2>title</h2>
<strong>some text here</strong>
   <img src="" alt="">
<p>some more text here.....</p>
END;
?>
and call it like:

PHP Code:
<table>
 <tr>
   <td><? echo $text?></td>
 </tr>
</table>
which will supply the following rendered source of:

PHP Code:
<table>
????: NamePros.com http://www.namepros.com/showthread.php?t=195831
 <
tr>
   <
td>
<
h2>title</h2>
????: NamePros.com http://www.namepros.com/showthread.php?t=195831
<
strong>some text here</strong>
   <
img src="" alt="">
<
p>some more text here.....</p>
</
td>
 </
tr>
</
table
I hope this helps you, if not please be more specific as to what you are trying to do.
Hobnob is offline  
Old 05-10-2006, 05:58 PM   #5 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
Join Date: Feb 2006
Posts: 2,796
Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future
 


Autism Autism Autism Autism Autism Autism Autism
Hobnob, that doesn't make any sense at all any doesn't make anything dynamic.

cesarian, I would help you, but I'm not sure where the things like '60 Minute Money' are coming from.

The PHP would be something like:

PHP Code:
<?php
????: NamePros.com http://www.namepros.com/showthread.php?t=195831

$file 
file('folders.txt');
foreach(
$file as $line) {
  echo 
the table stuff and $line is the line from the file..
}

?>
Dan is offline  
Old 05-11-2006, 04:34 AM THREAD STARTER               #6 (permalink)
NamePros Regular
Join Date: Mar 2006
Posts: 481
cesarian has a spectacular aura aboutcesarian has a spectacular aura about
 


Save a Life Child Abuse Animal Rescue AIDS/HIV
Hi, thank you for the reaply but they are not helping me. I tell you the original files.

template_menu.txt
There is actually only one line text here.
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://%site_url%/images/bullet.jpg"></td><td width="1061"><a style="font-family: Verdana; font-size: 11px; text-decoration: none" href="http://%site_url%/%site_folders%/">%menu_text%</a></td></tr></table>
pageterms.txt
There are here about 200 lines text. Example of the file:
Code:
Hallo
This
Is
Line
2
I have created a php file that replace the text %menu_text% with the text from pageterms.txt. So the line is multiplied with the script and on each new line the %menu_text% is replaced. This is what I use:
Code:
<?php
$menu_template = file_get_contents("template_menu.txt");
$text_array = file("pageterms.txt");

foreach($text_array as $text) {
    rows.=str_replace("%menu_text%",$text,$menu_template);
    
    if (!fwrite($handle, $menu_template)) {
       print "Can't write to file($menu_template)";
       exit;
   } else {
    fwrite ($handel, $rows);
    fclose ($handel);
}
Now I will reaplaced the %site_folders from a text file but I can not use foreach like this:
????: NamePros.com http://www.namepros.com/showthread.php?t=195831
Code:
$menu_template = file_get_contents("template_menu.txt");
$text_array = file("pageterms.txt");
$sitefolders_aray = file("folders.txt");
foreach(foreach($text_array as $text, $sitefolders_array as $sitefolders) {
    rows.=str_replace("%menu_text%",$text,$menu_template);
    rows.=str_replace("%site_folders%",$sitefolders,$menu_template);
    if (!fwrite($handle, $menu_template)) {
       print "Can't write to file($menu_template)";
       exit;
   } else {
    fwrite ($handel, $rows);
    fclose ($handel);
}
Can someone help me now? Thank you.
cesarian is offline  
Closed Thread


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


Liquid Web Smart Servers  
All times are GMT -7. The time now is 03:46 AM.

Managed Web Hosting by Liquid Web
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