Repalce content in html??

Reply

Join Date: Apr 2008
Posts: 293
Reputation: Aamit has a little shameless behaviour in the past 
Solved Threads: 11
Aamit Aamit is offline Offline
Posting Whiz in Training

Repalce content in html??

 
0
  #1
Sep 25th, 2009
Hi,This is my php file.
I want to replace
$$FullName$$ with Jon Rama
And $$FirstName$$ with Jon and $$Gender$$ with Male


And create to new file Jon_Rama.php

  1. <table width="100%">
  2. <tr>
  3. <td align="center">
  4. <b>
  5. <h1 class="title_list">$$FullName$$</h1>
  6. </b>
  7. <br><br>
  8. </td>
  9. </tr>
  10. <tr>
  11. <td>$$FirstName$$ is a $$Gender$$.</td>
  12. </tr>
  13. </table>

How to do this??
Last edited by Aamit; Sep 25th, 2009 at 5:39 pm.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 214
Reputation: chrishea is an unknown quantity at this point 
Solved Threads: 32
chrishea's Avatar
chrishea chrishea is offline Offline
Posting Whiz in Training

Re: Repalce content in html??

 
0
  #2
Sep 25th, 2009
If you are trying the process the code as data then you will probably want to use file_get_contents and file_put_contents to read and write the php file as if it were data.

You will then probably want a table of fields to check for and then scan the string read from the file and do a search and replace (str_replace) to substitute the new values.
Chris
See my list of PHP development tools at:
InnovationsDesign.net
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1,351
Reputation: almostbob has a spectacular aura about almostbob has a spectacular aura about 
Solved Threads: 163
almostbob's Avatar
almostbob almostbob is offline Offline
Nearly a Posting Virtuoso

Re: Repalce content in html??

 
0
  #3
Sep 26th, 2009
  1. <?php
  2. /* this file is called with url parameters ?firstname=Jon&lastname=Rama&gender=male
  3. full_name is a concatenation of firstname lastname */
  4. $full_name=$firstname.'_'.$lastname;
  5. $file = $full_name.'.php';
  6. if (file_exists($file)) { die("$file already exists"); }
  7. $text="<table width='100%'><tr><td align='center'><b><h1 class='title_list'>$firstname $lastname</h1></td></tr><tr><td>$firstname is a $gender.</td></tr></table>";
  8. $fp = fopen($file, "x");
  9. fputs ($fp, $text);
  10. fclose($fp);// Close the file.
  11. echo $file.' created'; ?>
If the data comes from an sql table the rows can be stepped through
If the data comes from a form the $_post array can be mined for data
Last edited by almostbob; Sep 26th, 2009 at 1:33 am.
Failure is not an option It's included free, you don't have to do anything to get it
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it

Please mark solved problems, solved
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC