4 Replies - 1877 Views - Last Post: 14 September 2009 - 03:30 PM Rate Topic: -----

#1 dog mikkyw  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 18
  • Joined: 17-October 08

Dynamic PHP File I/O to display in web page.

Post icon  Posted 13 September 2009 - 11:07 AM

I have a tester website I put before I put any code up for my parents business, and while trying to make a testimonial display box, I ran into some issues because I wanted to have php load the pages dynamically, here is the site. Testing Site. Never mind the colors, that's just so I can see visually how the code is working. Anyways, here is the php/html main portion of the site.
<html>
 <head>
	<title>Cop Shop Testimonials</title>
	<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.7.0/build/base/base-min.css" />
	<link rel="stylesheet" type="text/css" href="style.css" />
 </head>
 <body>
   <div id="wrap">
	  <div id="header-right">
		 <div id="header-left">
			<?php include ("header.php"); ?>
			</noembed>
		 </div>
	  </div>
	  <div id="content-right">
		 <div id="content-left">
			<?php include ("main.php"); ?>
			</noembed>
		 </div>
	  </div>
   </div>
   <noembed>
 </body>
</html>

Very simple looking, right? I like my code that way, anyways. The noembed tags are to remove t35 ads, seeing as it pins them to each of the include files. They don't give any problems. And here is my main.php file. (This is the one I try to get all dynamic with.)
<?php
$file = @fopen("TestimonialList.txt", "r");
if ($file) {
	while (!feof($file)) {
		$text = fgets($file, 2048);
		echo "$text<br />";
	}
	fclose($file);
}
?>
<noembed>

That reads from this list: Testimonial List
What I would like is maybe to have the web page automatically generated when a new addition is listed on that list. (Maybe incrementing creating testimonial2.php, testimonial3.php, etc.) And then have the Customer and the Text beneath be displayed, which would be from the main.php file.
I know this is a lot to ask, it's just that I'm a html/css guy and php is something I'm just starting to pick up, but I'd really appreciate some help, and I hope I've provided enough code for you guys here to get the "jist" of it.

Is This A Good Question/Topic? 0
  • +

Replies To: Dynamic PHP File I/O to display in web page.

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6246
  • View blog
  • Posts: 24,014
  • Joined: 23-August 08

Re: Dynamic PHP File I/O to display in web page.

Posted 13 September 2009 - 06:15 PM

If I understand you correctly, when a testimonial is added, you should open the file for append ("a"), and instead of fgets() like you do in reading, use fputs().
Was This Post Helpful? 0
  • +
  • -

#3 dog mikkyw  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 18
  • Joined: 17-October 08

Re: Dynamic PHP File I/O to display in web page.

Posted 13 September 2009 - 06:37 PM

View PostJackOfAllTrades, on 13 Sep, 2009 - 05:15 PM, said:

If I understand you correctly, when a testimonial is added, you should open the file for append ("a"), and instead of fgets() like you do in reading, use fputs().

Thanks for the reply. Yes, this is true for inputting the testimonials, but how would I make it so it reads them, using formatted based on the capitalized word that is before them. (AKA CUSTOMER: and TEXT:). If this isn't clear, just tell me. Thanks!
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6246
  • View blog
  • Posts: 24,014
  • Joined: 23-August 08

Re: Dynamic PHP File I/O to display in web page.

Posted 14 September 2009 - 09:09 AM

Your text file link returns a 404, so I don't know the format.
Was This Post Helpful? 0
  • +
  • -

#5 dog mikkyw  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 18
  • Joined: 17-October 08

Re: Dynamic PHP File I/O to display in web page.

Posted 14 September 2009 - 03:30 PM

Sorry, here it is.
http://copshopinc.t3...imonialList.txt
I changed my code a bit, I'm now using an array similar to this $arr = array(1=>"name one", 2=>"name two") etc etc, and then I'm searching for that name in the text, and printing the name and the subsequent line. And I'm using $_GET["id"] in order to get pages for the index of the array.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1