Page 1 of 1

What I would like to do is make a graphical interface to do

Posted: Wed Jun 14, 2006 2:03 am
by akimm
What I think needs to be done is like I use the terenary symbol for part, I think* the way I need to do this is make a option for say ?edit so then I'm thinking I need to make a variable $edit that will display all my words then print them with the proper formating, hopefully in time I can have a way to simply approve the submissions that wya I don't need to constantly FTP a textfile.

Code: Select all

<?php 
$part     = strtolower(substr($_GET['part'], 0, 1)); 
if (empty($part)) $part = "empty"; 
$fname    = "words.txt"; 

if (!file_exists($fname)) die("Sorry - the file you specified does not exist"); 
$handle   = fopen($fname, "r"); 
$string   = fread($handle, filesize($fname)); 
fclose($handle); 

function columnSort($unsorted, $column) { 
   $sorted = $unsorted; 
   for ($i=0; $i < sizeof($sorted)-1; $i++) { 
     for ($j=0; $j<sizeof($sorted)-1-$i; $j++) 
       if (strtolower($sorted[$j][$column]) > strtolower($sorted[$j+1][$column])) { 
         $tmp = $sorted[$j]; 
         $sorted[$j] = $sorted[$j+1]; 
         $sorted[$j+1] = $tmp; 
     } 
   } 
   return $sorted; 
} 

function printarray($entryarray,$part){ 
  $found = false; 
  for ($i=0;$i<count($entryarray);$i++){ 
    if (($part != "empty" && strtolower(substr($entryarray[$i]['word'], 0, 1)) == $part) || $part == "empty"){ 
      if (strtolower(substr($entryarray[$i]['word'], 0, 1)) != $char) { 
        $char = strtolower(substr($entryarray[$i]['word'], 0, 1)); 
        echo "<h2><a href=\"".$_SERVER['PHP_SELF']; 
        if ($part != $char) echo "?part=".$char; 
        echo "\">- ".$char." -</a></h2>\n"; 
      } 
      echo "<b>word:</b> ".$entryarray[$i]['word']." <b>definition:</b> ".$entryarray[$i]['definition']." <b>author:</b> ".$entryarray[$i]['author']." <br />\n"; 
      $found = true; 
    } 
  } 
  if (!$found) echo "No words by this letter have been added yet, be the first to add one click <a href='http://www.akimm.com/clairictionary/clairictionary.php'> here</a>!"; 
} 

$entryarray_old = explode("#entrysep#",$string); 
$entryarray = array(); 

for ($i=0;$i<count($entryarray_old);$i++){ 
  $dataarray = explode("#datasep#",$entryarray_old[$i]); 
  $entryarray[$i]['author']     = $dataarray[0]; 
  $entryarray[$i]['word']       = $dataarray[1]; 
  $entryarray[$i]['definition'] = $dataarray[2];  
} 

$entryarray = columnSort($entryarray, 'word'); 

printarray($entryarray,$part); 
?>

Posted: Wed Jun 14, 2006 2:22 am
by RobertGonzalez
Are you asking a question?

Yes

Posted: Wed Jun 14, 2006 2:33 am
by akimm
Let me rephrase.

I'm trying to figure out how to take information from a textfile that was put there via form
with $_POST['name'] $_POST['word'] $_POST['definition']

With this information, what i have to do now is go into a textfile ftp it to my desktop, edit it, which contains peoples submissions of the above $_POST statements, and then format them myself using

Example name#datasep#example word#datasep#example definition #entrysep#

What I would like to do is take this tedious process and create a form that i could do it with, and make the process more automated, as opposed to the FTP crap i need to do now.

Posted: Wed Jun 14, 2006 2:42 am
by RobertGonzalez
Why not set those changes at the time the form data is written to the file? It seems to be the easiest method, since the script is already grabbing the data, opening the files and writing to it. As your script does this, tell it to format the text file as well.

I didn't realize I could have it do that

Posted: Wed Jun 14, 2006 2:44 am
by akimm
I suppose though that would eliminate an entire step of creating the graphical interface, however, one thing I worry about and the reason I hessitate to use this method is because, if a fool is to use my program and write something senseless, or a spammer is, then I cannot have any means of filtering.

Any ideas on how i could acheive the following

Posted: Wed Jun 14, 2006 10:08 am
by akimm
if not i'll give itmy best and post updated code.

Posted: Wed Jun 14, 2006 11:14 am
by RobertGonzalez
Anytime you let users add their stuff to your stuff you run the risk of stupid crap making its way into your stuff. It's a risk you take when depending on others for content. Not your fault, just the way it is.