Chezshire Posted November 1, 2008 Share Posted November 1, 2008 I'm trying to make the names called in the following field display alphabetically, I've tried a number of things and nothing as worked correctly so I'm hoping someone here can help me out. Thanks for any and all help <?php if ($featuring && $charid) { ?> <tr><td align="right" width="100"><p><font color="#A5B9D5"><b>Who:</b></font></p></td><td width="10"></td> <td><p><font color="#A5B9D5"><?php list (($featuring, $charList) ORDER BY name) = linkCharsAdvanced($featuring, $id); echo $featuring; ?></font></p></td> </tr> This produces the following error message: Parse error: parse error, unexpected '}' in /home/content/z/a/n/zanland/html/xpg/messages/display.php on line 102 #102 list (($featuring, $charList) ORDER BY name) = linkCharsAdvanced($featuring, $id); Quote Link to comment Share on other sites More sharing options...
BoltZ Posted November 1, 2008 Share Posted November 1, 2008 <?php if ($featuring && $charid) { ?> <tr><td align="right" width="100"><p><font color="#A5B9D5"><b>Who:</b></font></p></td><td width="10"></td> <td><p><font color="#A5B9D5"><?php list (($featuring, $charList) ORDER BY name) = linkCharsAdvanced($featuring, $id); echo $featuring; ?></font></p></td> </tr> This produces the following error message: Parse error: parse error, unexpected '}' in /home/content/z/a/n/zanland/html/xpg/messages/display.php on line 102 #102 list (($featuring, $charList) ORDER BY name) = linkCharsAdvanced($featuring, $id); if ($featuring && $charid) { i assume you are trying to see if those variables exist. You use the isset function for that if (isset($featuring && $charid)) HTH Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted November 1, 2008 Share Posted November 1, 2008 er.. isset($var1, $var2) but you're trying to do something that makes no sense.. mysql query in php code? Quote Link to comment Share on other sites More sharing options...
BoltZ Posted November 1, 2008 Share Posted November 1, 2008 Yea I noticed that too, didn't wanna ask in case he actually needed to do that. Quote Link to comment Share on other sites More sharing options...
Chezshire Posted November 1, 2008 Author Share Posted November 1, 2008 Uhm, I'm not following half of what your saying at the moment, i'm very much a novice. Can you explain more on what your saying in relation to my question? Quote Link to comment Share on other sites More sharing options...
BoltZ Posted November 1, 2008 Share Posted November 1, 2008 In this code <?php if ($featuring && $charid) { ?> <tr><td align="right" width="100"><p><font color="#A5B9D5"><b>Who:</b></font></p></td><td width="10"></td> <td><p><font color="#A5B9D5"><?php list (($featuring, $charList) ORDER BY name) = linkCharsAdvanced($featuring, $id); echo $featuring; ?></font></p></td> </tr> Your doing ORDER BY sql code which is only used when connecting to a database and using a table in a database. Are you trying to output those variables alphabetically a-z? Quote Link to comment Share on other sites More sharing options...
Chezshire Posted November 1, 2008 Author Share Posted November 1, 2008 Hello - Yes I'm trying to output (Print/Echo) the names which is stored in the sql database alphabetically (A-Z). The names which populate the textfield are stored in the 'board' database and I just realized are in the field named 'featuring' not 'codename' (codename is used in a different database and that is my bad for having suggested otherwise when asking for help). So i've tried the following but i'm still not getting the effect i want: <?php if ($featuring && $charid) 'ORDER BY featuring'; { ?> <tr><td align="right" width="100"><p><font color="#A5B9D5"><b>Who:</b></font></p></td><td width="10"></td> <td><p><font color="#A5B9D5"><?php list ($featuring, $charList) = linkCharsAdvanced($featuring, $id) ; echo $featuring; ?></font></p></td> </tr> Quote Link to comment Share on other sites More sharing options...
Flames Posted November 1, 2008 Share Posted November 1, 2008 if ($featuring && $charid) 'ORDER BY featuring'; { why is ordering by featuring there as far as i know you need a { straight after the closing bracket of an if statement. Quote Link to comment Share on other sites More sharing options...
Chezshire Posted November 1, 2008 Author Share Posted November 1, 2008 HI Flames -- If you missed the part earlier where I said 'i dont' know what i'm doing' , let me reiterate that I don't know what I'm doing. I just guess a lot and poke and prod until i'm able to get my code to do what I'm trying to get it to do. (I'm dyslexic so a lot of stuff confuses me -- and i'm not a coder - complete ameteur). The 'ORDER BY featuring' is where it is as thats the last place i tried sticking it to see where it might go to achieve the effect i want. I tried puting it in several places. If someone can help me to figure out where it should go that would be great - or if thats even the way to do it. Thanks! Quote Link to comment Share on other sites More sharing options...
marcus Posted November 1, 2008 Share Posted November 1, 2008 Well if either of your variables are arrays you can use natcasesort to sort them. Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted November 1, 2008 Share Posted November 1, 2008 Can you post your full code including the query statement? Quote Link to comment Share on other sites More sharing options...
Chezshire Posted November 1, 2008 Author Share Posted November 1, 2008 Will do, Although to those who respond please note that I was asked to post the full code, please do not flame me for doing so (Thank you) <?php include ("../functions.php"); approvevars(array("id", "hideHeaders")); if (!$id) { header ("location: /messages.php"); die; } $sql = "SELECT *, DATE_FORMAT(lastmodified,'%b %e @ %h:%i %p') AS modformat, TO_DAYS(NOW()) - TO_DAYS(lastmodified) as modage, DATE_FORMAT(DATE_ADD(NOW(),INTERVAL -3 HOUR),'%Y%m%d%H%i%s') as currentTime, DATE_FORMAT(gamedate,'%b %e, %Y') AS gamedate FROM board WHERE id=$id"; $result=mysql_query($sql); $post = mysql_fetch_assoc($result); $currentTime = $post["currentTime"]; $thread = $post["thread"]; $locked = threadLocked($thread); if (!$thread) { $thread = $id; } // LET"S UPDATE NOTIFICATION IF NEEDED reinstateNotification($thread); $fields = array("subject","content","charid","storyteller","summary","previously","thread","delete","ooc","featuring","tags","timeofday","location","userid", "gamedate","continuedfrom", "modage", "lasteditor", "modformat"); $patterns = array ("/\"/","/[\r\f\n]+/","/ *\.\.\.+ */","/<p><hr><\/p>/","/<hr>/"); $replace = array (""","</p>\n<p>", "… ","<hr color='#050F1D' size='5' width='300' align='center'>","</p>\n<hr color='#050F1D' size='5' width='300' align='center'>\n<p>"); FOREACH ($fields as $thisField) { if (isset($post[$thisField])) { ${$thisField} = $post[$thisField]; ${$thisField} = preg_replace($patterns,$replace,${$thisField}); } else { ${$thisField} = ""; } } // end foreach // if it isn't the only post in a thread, lets find out where it falls $sql = "SELECT id FROM board WHERE thread=$thread AND approved <> '' AND approved IS NOT NULL ORDER BY dateadded"; $result = mysql_query($sql); $total = mysql_num_rows($result); $thisPost=""; $prevPost=""; $nextPost=""; $i=0; $j=""; WHILE ($tempy = mysql_fetch_assoc($result)) { $i++; // If we've officially set "thisPost", set the Next post (but only if it's not already set) if ($thisPost && !$nextPost) { $nextPost = $tempy["id"]; } if ($id==$tempy["id"]) { $thisPost = $i; $prevPost = $j; } // set the id to J so it can be saved next time. $j = $tempy["id"]; } // end thread check echo "<!-- Hide headers? $hideheaders -->\n"; $pageTitle = "Messages » " . getThreadName($thread) . " ($thisPost of $total)"; include ("../header.php"); ?><table cellpadding="1" cellspacing="0"> <tr><td colspan="3"><h1><?php if ($charid || $storyteller) { $fontcolor="#A5B9D5"; } else { $fontcolor = "#00CC99"; } echo "<font color='$fontcolor'>" . getThreadName($thread); ?></font></h1> <p class="fineprint"><b><?php if (!$thisPost) { echo "<font color='red'>Message not approved.</font> "; } else { echo "Message $thisPost of $total. "; } echo "<font color='#666666'>[#$id]</font> "; echo "<a href=\"/messages/thread.php?thread=$thread"; if ($hideHeaders) { echo "&hideHeaders=$hideHeaders"; } echo "\" title=\"View entire thread\">[View entire thread…]</a><br>\n"; if ($prevPost) { echo "<a href=\"/messages/display.php?id=$prevPost"; if ($hideHeaders) { echo "&hideHeaders=$hideHeaders"; } echo "\" title='Go to previous message in this thread'><img src=\"/images/back.gif\" height=\"13\" width=\"20\" border=\"0\"></a>"; } if ($nextPost) { echo "<a href=\"/messages/display.php?id=$nextPost"; if ($hideHeaders) { echo "&hideHeaders=$hideHeaders"; } echo "\" title='Read the next message in the thread'><img src=\"/images/forward.gif\" height=\"13\" width=\"20\" border=\"0\"></a>"; } if ($moderator || (($login == $userid) && $userid)) { echo "<a href=\"/messages/post.php?id=$id\" title='Make changes to this message'><img src=\"/images/edit.gif\" height=\"13\" width=\"37\" border=\"0\">"; if ($moderator && $lasteditor && $dateadded != $lastmodified && $modage < 15) { echo " <span class='fineprint' style='color:#666666'>[Last edit: " . getName($lasteditor) . ", $modformat]</span>"; } echo "</a>"; } ?></p> <hr color="#050F1D" size="5"></td></tr> <tr><td align="right" width="100"><p><b><font color="<?php echo $fontcolor; ?>">Subject:</b></font></p></td><td width="10"></td> <td><p><font color="<?php echo $fontcolor; ?>"><?php if (!$charid && !$storyteller) { echo "[OOC] "; } echo $subject; ?></font></p></td> </tr> <?php if ($featuring && $charid) 'ORDER BY featuring'; { ?> <tr><td align="right" width="100"><p><font color="#A5B9D5"><b>Who:</b></font></p></td><td width="10"></td> <td><p><font color="#A5B9D5"><?php list ($featuring, $charList) = linkCharsAdvanced($featuring, $id) ; echo $featuring; ?></font></p></td> </tr> <?php } // end if featuring if ($location && $charid) { ?><tr><td align="right" width="100"><p><font color="#A5B9D5"><b>Where:</b></font></p></td><td width="10"></td> <td><p><font color="#A5B9D5"><?php echo stripslashes($location); ?></font></p></td> </tr> <?php } // end if location if (($timeofday || $gamedate) && $charid) { $tempy = array(); if ($timeofday && $gamedate) { array_push($tempy,$timeofday); array_push($tempy,$gamedate); } else if ($timeofday) { array_push($tempy,$timeofday); } else if ($gamedate) { array_push($tempy,$gamedate); } $dateandtime = implode(", ", $tempy); ?><tr><td align="right" width="100"><p><font color="#A5B9D5"><b>When:</b></font></p></td><td width="10"></td> <td><p><font color="#A5B9D5"><?php echo $dateandtime; ?></font></p></td> </tr> <?php } // end if timeofday if ($previously) { ?><tr><td align="right" valign="top" width="100"><p><font color="<?php echo $fontcolor; ?>"><b>Previously:</b></font></p></td><td width="10"></td> <td><p><font color="<?php echo $fontcolor; ?>"><?php echo stripslashes($previously); ?></font></p></td> </tr> <?php } // end if previously if ($continuedfrom) { ?><tr><td align="right" valign="top" width="100"><p><font color="#A5B9D5"><b>Continued from...</b></font></p></td><td width="10"></td> <td><p><a href='/messages/display.php?id=<?php echo $continuedfrom; if ($hideHeaders) { echo "&hideHeaders=$hideHeaders"; } ?>' title='Read this message'><?php echo getSubject($continuedfrom); ?></a></font></p></td> </tr> <?php } // end if continued from ?> <tr><td colspan="3"><hr color="#050F1D" size="5"></td></tr> <tr><td colspan="3"><p><?php $characterName = getChar($charid); if ($characterName == "Storyteller" && $charid) { $storyteller = "Storyteller"; } if ($storyteller) { $charid=""; } if ($charid || $storyteller) { $content = preg_replace("/\[([Tt]ag[^\]\[]+)\]/","<font color='#A5B9D5'>[$1]</font>",$content); $content = preg_replace("/\[([Tt]ag[^\]\[]+)\]/","<font color='#A5B9D5'>[$1]</font>",$content); $content = hrefCheck($content); if (!$pref["litegraphics"]) { if ($storyteller) { echo "<img src=\"/images/circle-x.jpg\" width=\"200\" border=\"0\" align=\"right\" hspace=\"10\"></a>"; } else { echo "<a href='/cerebra/display.php?id=$charid' title='Get info on the character: $characterName'><img src=\"/cerebra/images/resizer.php?id=$charid&width=200\" width=\"200\" border=\"0\" align=\"right\" hspace=\"10\"></a>"; } // end if storyteller } // end if LITE if ($charid) { echo "<a href='/cerebra/display.php?id=$charid' title='Get info on the character: $characterName'>$characterName</a>: "; } else { echo "<font color=\"$fontcolor\"><b>$storyteller</b>:</font> "; } // end if charid/storyteller echo stripslashes($content) . "</p>"; } else { $thisPlayer = getName($userid); $ooc = hrefCheck($ooc); echo "<a href='/profile.php?id=$userid' title='Get info on the player: $thisPlayer'><font color=\"$fontcolor\">$thisPlayer</font></a>: " . stripslashes($ooc); ?></p><?php } // end if OOC $testy = mysql_query("SELECT id,subject from board WHERE continuedfrom = $id AND approved <> '' AND approved IS NOT NULL ORDER BY dateadded DESC"); if ($nextPost) { echo "<p><a href=\"/messages/display.php?id=$nextPost"; if ($hideHeaders) { echo "&hideHeaders=$hideHeaders"; } echo "\" title='Read the next message in the thread'>[Next message…]</a></p>"; } if (mysql_num_rows($testy)) { $continuedin=array(); WHILE ($thisMsg = mysql_fetch_assoc($testy)) { $msgLink = "<a href=\"/messages/display.php?id=" . $thisMsg["id"]; if ($hideHeaders) { $msgLink .= "&hideHeaders=$hideHeaders"; } $msgLink .= "\" title='Read this "spin-off" message'>" . $thisMsg["subject"] . "</a>"; array_push($continuedin, $msgLink); } // end WHILE $continuedString = implode(", ", $continuedin); echo "<p><font color=\"#A5B9D5\"><b>"; if ($nextPost) { echo "Also c"; } else { echo "C"; } echo "ontinues in thread(s):</b></font> $continuedString</p>\n"; } // end if continuing elsewhere if ((!$locked || $moderator) && !$hideHeaders) { echo "<hr color=\"#050F1D\" size=\"5\">\n"; echo "<p>"; $addPipe=""; if (!$nextPost && !mysql_num_rows($testy)) { echo "<a href='/messages/post.php?thread=$thread' title='Post to this thread'>[Add Post to this thread…]</a>"; $addPipe = "true"; } // end if allowed to add to the end if ($addPipe) { echo " | "; } echo "<a href=\"/messages/post.php?continuedfrom=$id\" title='Post a new thread with this message as a starting point'>[spin-off a new thread…]</a>"; echo "</p>"; } // end if locked ?></p></td></tr> <tr><td colspan="3"><hr color="#050F1D" size="5"></td></tr> <?php if ($summary) { ?><tr><td align="right" valign="top"><p><font color="<?php echo $fontcolor; ?>"><b>Summary:</b></font></p></td><td width="10"></td> <td><p><font color="<?php echo $fontcolor; ?>"><?php echo stripslashes($summary); ?></font></p></td> </tr> <?php } // end if summary ?> <?php if ($ooc && ($charid || $storyteller)) { ?><tr><td align="right" valign="top"><p><font color="<?php echo $fontcolor; ?>"><b>OOC Notes:</b></font></p></td><td width="10"></td> <td><p><font color="#A5B9D5"><?php $ooc = hrefCheck($ooc); echo stripslashes($ooc); ?></font></p></td> </tr> <?php } // end if OOC ?> <?php if ($tags) { ?><tr><td align="right" valign="top"><p><font color="<?php echo $fontcolor; ?>"><b>Tags:</b></font></p></td><td width="10"></td> <td><p><font color="#A5B9D5"><?php $tags = linkChars($tags); echo stripslashes($tags); ?></font></p></td> </tr> <?php } // end if tags if ($storyteller && $characterName != "Storyteller") { ?><tr><td align="right" valign="top"><p><font color="<?php echo $fontcolor; ?>"><b>Storyteller:</b></font></p></td><td width="10"></td> <td><p><?php echo "<a href='/profile.php?id=$userid' title='Get info on player: " . getName($userid) . "'>" . getName($userid) . "</a>"; ?></p></td> </tr> <?php } // end if OOC ?> </table> <?php if (count($charList)) { FOREACH ($charList as $charid) { echo "<div id='cerebra_tooltip_$charid' style='display:none; padding: 5px; width:200px; background-color: black; border: solid 1px #415582;'>"; $tooltip_id = $charid; include("../cerebra_tooltip.php"); echo "</div>\n\n"; } // end foreach ?> <script type="text/javascript"> <?php FOREACH ($charList as $charid) { echo "var my_tooltip_$id = new Tooltip('cerebra_{$charid}_$id', 'cerebra_tooltip_$charid')\n"; } // end foreach ?> </script> <?php } // end if charList to show include("../footer.php"); ?> Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted November 1, 2008 Share Posted November 1, 2008 wow, okay... why are you ordering it by "dateadded" then suddenly are deciding later that you want to order it by "featuring" Quote Link to comment Share on other sites More sharing options...
Chezshire Posted November 1, 2008 Author Share Posted November 1, 2008 Date added is called is for the post itself, the featuring is 'who' has posted in the thread so far. I want the display to list people in alphabetical manner. I don't know if this will help but here is an example of the php in action: The first URL shows an individual post displaying: http://www.xpg.us/messages/display.php?id=14053 The second URL shows all the collective posts in 'thread' view: http://www.xpg.us/messages/thread.php?thread=13924 I've been working on this site for eight years (a friend who is great with PHP helped me get started and i just maintain it and try to make improvements when and where I can -- this one didn't seem to hard to so i'm trying to do it, but as is always the case, when i think 'that doesn't seem hard' if often turns into a weekend of frustration Thanks for any help Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted November 1, 2008 Share Posted November 1, 2008 Sorry, I just can't read this code... no indentation, no comments, no consistency, and there are user-defined functions all over the place where I have no idea what they do. Quote Link to comment Share on other sites More sharing options...
Chezshire Posted November 1, 2008 Author Share Posted November 1, 2008 Thanks for the help - i'll just keep poking away at it Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.