Jump to content

[SOLVED] search and post help needed


Flustered

Recommended Posts

I have the following start to a code that I need, I need it to read a file called modifiers.txt and return all the lines with "war between" in it, with a maximum of 10 lines returned, and reading from the latest line to the oldest. Thx all!!

 


<?php 
include("config.php"); 

$irpg_page_title = "War Report"; 

include("header.php"); 
include("commonfunctions.php"); 
    echo "<h1><font color=red>War Report</font></h1>\n"; 

-------------- 
code to detect trigger words from modifiers.txt and post to html 
     if "war between" isin modifiers.txt 
    echo line to html 
    maximum of 10 lines 
---------------------- 
?> 
<? 
    include("footer.php"); 
?>

Link to comment
Share on other sites

This is an example of the line I need read..

 

[07/07/08 19:12:11] The war between the four parts of the realm has shown the power of the Southeast [2148/2963], whereas it led the Northeast [13/1264] to perdition. The diplomacy of the Southwest [1729/1757] and the Northwest [1248/2181] was admirable.

Link to comment
Share on other sites

Directly asking for an entire code will not get you a good reputation here. But since I'm bored...

 

Edit: Didn't see the last line of your first post...

 

<?php

$txt = fopen( "modifiers.txt", "a+" );
$lines = 0;
while ( !feof( $txt ) ) {
if ( ereg( "war between", fread( $txt, 512 ) ) && $lines < 10 ) {
	print str_replace( "war between", "<strong>war between</strong>", fread( $txt, 512 ) ) . "<br />\n";
	$lines += 1;
}
}
fclose( $txt );

?>

Link to comment
Share on other sites

I really appreciate your help, I'm very new to trying this. I tried the code below and the page opens, but very slowly. The page shows the "War Report:" , but is blank from there on. It doesn't show the results from modifiers.txt or the footer. Did I do the structure wrong or??  Thx again!!

 

 


<?php 
include("config.php"); 

$irpg_page_title = "War Report"; 

include("header.php"); 
include("commonfunctions.php"); 

echo "<h1>War Report:</h1>\n"; 

$txt = fopen( "modifiers.txt", "a+" );
$lines = 0;
while ( !feof( $txt ) ) {
if ( ereg( "war between", fread( $txt, 512 ) ) && $lines < 10 ) {
	print str_replace( "war between", "<strong>war between</strong>", fread( $txt, 512 ) ) . "<br />\n";
	$lines += 1;
}
}

fclose( $txt );

?> 
<? 
    include("footer.php"); 
?> 


Link to comment
Share on other sites

Thanks you very much for the help! This is showing results now, but I need it to show the results from the most recent back. It is showing the first 10 since the bot was started, so it will never change. The modifier lines are formatted like:

 

[06/20/08 18:35:59] The war between the four parts of the realm has shown the power of the Southeast [153/361] and the Northwest [81/200], whereas it led the Northeast [0/0] and the Southwest [68/227] to perdition.

[06/21/08 18:41:17] The war between the four parts of the realm has shown the power of the Northwest [304/311], whereas it led the Northeast [1/255] to perdition. The diplomacy of the Southeast [23/33] and the Southwest [99/274] was admirable.

 

Is there a way to get it to read the date and go from the most recent backwards??

 

Thanks again for the help!!

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.