What I would like to do is make a graphical interface to do
Posted: Wed Jun 14, 2006 2:03 am
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);
?>