Jump to content

9999

Members
  • Posts

    99
  • Joined

  • Last visited

    Never

Everything posted by 9999

  1. Thank you.  It works well.  I did not copy and paste very well - lol.
  2. Intersting.  Let me double check everything I have snd I will get back with you. Thanks
  3. The output line: [code]echo '<b><font face="Times New Roman">' . $count . '--' . $month  . '&nbsp;' . $day . ',&nbsp;' . $year . '--' .'</font></b>';[/code] still shows, December 31, 1969 for all records that have a year value less than 1970.  I am using PHP 4.3.11 Do you think any other lines of code should be changed?  How does changing the months affect the script? 
  4. Why would you want to do that when you could get paid using adsense?
  5. This is the form where the keyword are inputted [code]<form action="search.php" method="get">   <input type="text" name="search" size="20">   <input type="hidden" name="usersearch" value="1"/>   <input type="submit" value="Search"/> </form>[/code]
  6. I use F j Y format so todays date would looklike this: August 30, 2006 and the date you mentioned would look this this: January 1, 1969
  7. Thanks, I am a newbie and have had help with my code.  Given my code above, what changes would I make to make this work for me?
  8. That didn't work.  It just changed all my values to two-thousand and something. This is the line from my above code that I am refering to: [code]$matches[strtotime("$day $month $year")][] = preg_replace($pattern, '<span style="color:red;">$1</span>', $info);[/code]
  9. Is there a few lines of code that might make it recognize dates before 1970?
  10. They use the GET method so you could do as i.ve seen before and copy the address of the results page and open that in an iframe I suppose. [code]<div id="iFrame1" style="position:absolute; left:1px; top:1px; z-index:0"> <iframe name="iFrame1" width=600 height=800 src="http://www.google.com/search?client=opera&rls=en&q=php+help&sourceid=opera&ie=utf-8&oe=utf-8" scrolling="auto" frameborder="1"></iframe></div>[/code] LOL phpfeaks comes up first in a google search for php help  ;D
  11. Get a google adsense account and follow these instructions: https://www.google.com/support/adsense/bin/answer.py?answer=42857&sourceid=aso&subid=ww-ww-et-asui&medium=link
  12. Hi, I'm using a delimiteed text file as a database.  It contains 4 fieds: $day, $month, $year, and $info.  I have a search script that searches the $info field against keywords a user can input then displays the results SORTED by $year.  Everything works fine except for any record that contains a $year value before 1970 (the epoch) it treats it as December 31, 1969 and wrecks my sort order.  Given the following script, what can I do to fix this? [code]if($_REQUEST['usersearch'] == '1')  // Display Keyword Search Results {     $file = file('data.txt');     $search = $_GET['search'];     $file = file('data.txt');     $keys = preg_split('/[\s,]+/', preg_replace('/([^a-z0-9\s])/i', '', trim($search) ) );     if (sizeof($keys) > 5)     {         die("Please enter less keywords.");     }     else if (empty($keys[0]))     {         die("Please enter a valid keyword.");     }     $pattern = '/('. implode('|', $keys) .')/i';     $matches = array();     $matchcount = 0;     foreach (array_values($file) AS $data)     {         list($month, $day, $year, $info) = explode('|', trim($data) );         if (preg_match($pattern, $info))         {             $matches[strtotime("$day $month $year")][] = preg_replace($pattern, '<span style="color:red;">$1</span>', $info);             $matchcount++;         }     }     if (sizeof($matches) > 0)     {         ksort($matches);         $count = 0;         printf('<center><b><p>%d match%s found.</p></b></center>', $matchcount, $matchcount == 1 ? NULL : 'es');         foreach ($matches AS $days => $event)         {             foreach ($event AS $result)             {                 list($month, $day, $year) = explode('-', date('F-j-Y', $days) );                 $count++;                 echo '<b><font face="Times New Roman">' . $count . '--' . $month  . '&nbsp;' . $day . ',&nbsp;' . $year . '--' .'</font></b>';                 echo '<font face="Times New Roman" size="2px">' . $result .'</font>';                 echo "<p>";                 if ($count >= 200)                 {                     break;                 }             }             if ($count >= 200)             {                 break;             }         }         printf('<center><b><p>%d match%s found.</p></b></center>', $matchcount, $matchcount == 1 ? NULL : 'es');     }     else     {         echo '<p><center><b>No results were found for your search--Please try again.</b></center></p>';     } }[/code] Thanks in advance
  13. Ok but what if my $info contains 3 sentences?  Would this work after each one or just the last one>
  14. In my database, for a given record, the $info field might contain multiple sentences that have the standard 2 spaces after the period.  When that record is extracted and echoed, there is only one space after the period.  It does it in every case.  I thought the trim function was causing it, but it does it even when I remove it.
  15. This piece of code searches the $info field of my delimited text file database: [code]foreach ($file as $line => $data) {     list($month, $day, $year, $info) = explode('|', trim($data) );     if (stristr($info, $search))     {     echo $info;     } }[/code] I have 3 Questions: 1) Lets say a person was searching for "John Smith" they could enter "John Smith" or "John" or "Smith" and it would work.  I would like to improve my search so that if a person searched for "John Smith" it would also find results for "John T. Smth" or " John Q. Smith" etc.  Is there an easy way to do this? 2)  How can I sort the $year field? 3)  For each record, the data in my $info is 2 or 3 sentences long.  When the current script returns a result, there is only 1 space between sentences even though there are 2 in my database.  Any suggestions on how I can fix this? Thanks in advance
  16. What would the correct syntax for the "if" line be?
  17. I am making a quiz that will consist of 10 questions.  The form will post to a PHP script for grading.  Due to space limits I want to put 5 questions on one page (quiz.html) with a continue button on the bottom that takes you to the second page (quiz2.html) were the user will "submit" their answers.  How do you get the answers from the first page to carry over and post with the stuff from page 2? Thanks in advance
  18. What about something like this: [code]if (in_array(stristr($search, $blocked)))[/code] Could this work with some modification?
  19. Thanks guys for your help.  I was still wondering if there is anything I can do with my existig code to make it work; particularly this line [code]if (stristr($search, $not_allowed))[/code] as I already have a complicated maze of nested loops and such.
  20. This is a snipet of code I have.  I eventually may want to increase this list to 10 words.  What am  I doing wong? [code]$search = $_GET['search']; $not_allowed = array('and', 'or', 'of', 'is', 'the'); if (stristr($search, $not_allowed))         {             echo 'Your search contains a word that is not allowed';         }[/code]
  21. Thank you kindly Jocka. angelb0y:  Yes, that is the function of the iframe.  What I did was, I took "myphpfile.php" and put that code directly into my "index.php" page so I was not able to call it as I normally would.
  22. Could I declare the entire php code block a function then put that function name in the src of the iframe
  23. If I have a php file: [code]<?php //60 or 70 lines of php code here ?>[/code] How would I put this in an iframe? I tried the following which didn't work [code]<iframe src= <?php //60 or 70 lines of php code here ?> </iframe>[/code]
  24. On my index page I display the date and some "tips of the day" (tip.php-displayed in an iframe) derived from a delimited text file. [code] <div align="center"  <?php    echo date("<b>F j</b>");  ?>  </div> [/code]  [code]<?php //tip.php This displays on the index page in an iframe  $file = file('data.txt');  $today = getdate();  echo'<table style="width:400px; height:200px; padding:0px; border:0px"><tr><td>';  foreach ($file as $line => $data)  {      list($month, $day, $year, $tip) = explode('|', trim($data) );        if ($today['month'] == $month AND $today['mday'] == $day)    {              echo '<font face="Times New Roman" size="2px">'. $tip .'</font>';          echo "<p>";        }  }  echo'</td></tr></table>';  ?> [/code] The iframe html[code]<iframe name="iFrame1" width=425 height=225 src="tip.php" scrolling="auto" frameborder="0"></iframe>[/code] After viewing that, the view would then be able to select another day of the year and go to that result: html[code]<form action="select.php" method="POST"> <select name="month">   <option value="January">January             ***  thru ****   <option value="December">December </select> <select name="day">   <option value="1">1         ***  thru ***   <option value="31">31 </select>   <input type="submit" name="Get Tip" value="Get Tip"/> </form>[/code] That form submission then posts to select.php which is here: [code]<?php  // from select.php  $monthselect = $_POST['month'];  $dayselect = $_POST['day'];  $file = file('data.txt');  echo'<table style="width:400px; height:200px; padding:0px; border:0px"><tr><td>';  foreach ($file as $line => $data)  {      list($month, $day, $year, $tip) = explode('|', trim($data) );        if ($monthselect == $month AND $dayselect == $day)    {              echo '<font face="Times New Roman" size="2px">'. $tip .'</font>';          echo "<p>";        }  }  echo'</td></tr></table>';  ?> [/code] My problem is that this output is printed on a blank page. I want to display it as I do the original tip.php file that was displayed on my index page. I would prefer if this output was displayed on a regenerated index page. Any suggestions as to what code I would use? Using sessions was suggested but I don't know how I would implement that in my case. Is there another solution? I am a newbir to both php and web developing.  I use two files instead of one and I use iframes because that is what I am comfortable with at this juncture. Thanks in advance!
×
×
  • 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.