
Showcase
Members-
Posts
15 -
Joined
-
Last visited
Never
Everything posted by Showcase
-
I'm not saying put the post id in the forums table, I'm saying create a new feild in the posts table and store the board id in that. When processing the post, pass the forum id along with the contents, name, subject, etc. Then, after form validation, when inserting into the posts database table, insert the board id that was passed into the new board id feild as well. Then when loading the forum in board.php, run a mysql query to select the posts where board_id = the board's id.
-
After a quick look, it seems in post.php when you're inserting the post it is not inserting any board reference id. Therefore, it's not adding the id for what board section it is being posted in. Then, in board.php, it needs to grab the topics that contains the board's id.
-
Looked through your code and saw what seemed to be problems in your html. This may not fix it, but try it and see what happens. Here's the entire adjusted code: <table width="650" border="1" cellpadding="0" cellspacing="0" bordercolor="#FF0000"> <tr> <td align="center" class="style5"><strong>World Leaders</strong></td> </tr> </table> <br> <table width="54%" border="0" align="left"> <tr> <th width="8%" /> <th width="26%"><b>Username</b></th> <th width="16%"><strong>Position</strong></th> <th width="20%"><strong>Status</strong></th> </tr> <?php //Select all members ordered by level (highest first, members table also doubles as rankings table) $query = $db->execute("select `id`, `username`, `staff`, `banned`, `rm`, `ncolor`, `last_active` from `players` order by `staff` desc limit 50"); while($member = $query->fetchrow()) { //This is to stop people being displayed if their staff is lower than 1. if($member['staff'] >= 1) { echo "<tr>"; echo "<td />"; echo "<td><a href=\"profile.php?id=" . $member['username'] . "\">"; //This displays the username of each person (in different colors. if ($member['banned'] >= 1) { echo "<b>[b] </b>"; echo "<STRIKE>" .$member['username']. "</STRIKE></td>"; } else if ($member['ncolor'] == 1) { echo "<font color=\"blue\">".$member['username']."</font></td>"; } else if($member['ncolor'] == 2) { echo "<font color=\"green\">".$member['username']."</font></td>"; } else if($member['ncolor'] == 3) { echo "<font color=\"yellow\">".$member['username']."</font></td>"; } else if($member['ncolor'] == 4) { echo "<font color=\"pink\">".$member['username']."</font></td>"; } else if($member['ncolor'] == 5) { echo "<font color=\"silver\">".$member['username']."</font></td>"; } else if($member['staff'] >= 1) { echo "<font color=\"gold\">".$member['username']."</font></td>"; } else if($member['rm'] >= 1) { echo "<font color=\"red\">".$member['username']."</font></td>"; } else { echo "<td><font color=\"\">".$member['username']."</font></td>"; } //This shows the Position held by the user. if($member[`staff`] == 1) { echo "<td><font color=\"red\">Forum Moderator</font></td>"; } else if($member[`staff`] == 2) { echo "<td><font color=\"red\">Moderator</font></td>"; } else if($member[`staff`] == 3) { echo "<td><font color=\"red\">Global Moderator</font></td>"; } else if($member[`staff`] == 4) { echo "<td><font color=\"red\">Admin</font></td>"; } else if($member[`staff`] == 5) { echo "<td><font color=\"red\">Owner</font></td>"; } else { echo "<td><font color=\"red\">None</font></td>"; } //This shows if the user is on or offline. if ($member['last_active'] >= Time()-1200) { echo "<td><font color=\"lime\">Online</font></td>"; } else { echo "<td><font color=\"red\">Offline</font></td>"; } echo "</tr>"; } } ?> </table> You were missing a lot of closing tags. The new table row tags are in there as well.
-
You're missing "</td>" at the end of all your ncolor check echos. And you're not starting and ending a new <tr> table row at the start and end of each loop.
-
else if($member[`staff`] == 1) { echo "<td><font color=\"red\">Forum Moderator</font></td>"; } else if($member[`staff`] == 2) I'm guessing position = staff value. The problem looks like the first if that's checking the staff value is an else if, so it's "else iffing" off of the banned and ncolor checks. Some commenting between those if blocks would make this a bit easier to read and track down. And I don't know what kind of values exist in your database but storing the colors and positions into arrays than simply checking if the value exists in ncolor and staff could knock out a lot of those if statements like this: <table width="650" border="1" cellpadding="0" cellspacing="0" bordercolor="#FF0000"> <tr> <td align="center" class="style5"><strong>World Leaders</strong></td> </tr> </table> <br> <table width="54%" border="0" align="left"> <tr> <th width="8%"> <th width="26%"><b>Username</b></td> <th width="16%"><strong>Position</strong> <th width="20%"><strong>Status</strong> </tr> <?php $colors = array("blue","green","yellow","pink","silver"); $positions = array("Forum Moderator","Moderator","Global Moderator","Admin","Owner"); //Select all members ordered by level (highest first, members table also doubles as rankings table) $query = $db->execute("select `id`, `username`, `staff`, `banned`, `rm`, `ncolor`, `last_active` from `players` order by `staff` desc limit 50"); while($member = $query->fetchrow()) { if($member['staff'] >= 1) { echo "<td>"; echo "<td><a href=\"profile.php?id=" . $member['username'] . "\">"; if ($member['banned'] >= 1) { echo "<b>[b] </b>"; echo "<STRIKE>" .$member['username']. "</STRIKE></td>"; } else if ($member['ncolor'] != NULL) { echo "<font color=\"".$colors[$member['ncolor']]."\">".$member['username']."</font>"; } else if($member['staff'] >= 1) { echo "<font color=\"gold\">".$member['username']."</font>"; } else if($member['rm'] >= 1) { echo "<font color=\"red\">".$member['username']."</font>"; } else { echo "<td><font color=\"\">".$member['username']."</font></td>"; } if($member[`staff`] != NULL) { echo "<td><font color=\"red\">".$positions[$member['staff']]."</font></td>"; } if ($member['last_active'] >= Time()-1200) { echo "<td><font color=\"lime\">Online</font></td>"; } else { echo "<td><font color=\"red\">Offline</font></td>"; } } } ?> </table> You might have to change a few things based on the values in your database but something like that should work.
-
PHP Help! Changeing values in a mysql db form php
Showcase replied to madmaninamini's topic in PHP Coding Help
I guess you're asking for mysql help. UPDATE table_name SET kit_quantities='3,5', kits='1,2' WHERE id=2 SET is for changing feilds, multiple feilds are separated by commas. WHERE is for matching a feild to editing it's row. -
The problem is probably $num = mysql_num_rows($query); I didn't bother reading past that. $query isn't holding any mysql result set, it's just holding the query information that is being sent to the database using mysql_query(). The result set from that query is being stored into $result. Replace: $query = "SELECT full_name,user_idnum,DATE_FORMAT(`date`, '%m/%d/%Y %I:%i %p'),book,returned, MATCH (full_name) AGAINST ('".$search."' IN BOOLEAN MODE) AS user_idnum FROM `checkout` WHERE MATCH (user_idnum) AGAINST ('".$search."' IN BOOLEAN MODE) ORDER BY `full_name` DESC"; $result = mysql_query($query); $query = "SELECT full_name,user_idnum,DATE_FORMAT(`date`, '%m/%d/%Y %I:%i %p'),book,returned, MATCH (full_name) AGAINST ('".$search."' IN BOOLEAN MODE) AS user_idnum FROM `checkout` WHERE MATCH (user_idnum) AGAINST ('".$search."' IN BOOLEAN MODE) ORDER BY `full_name` DESC"; $num = mysql_num_rows($query); With: $query = "SELECT full_name,user_idnum,DATE_FORMAT(`date`, '%m/%d/%Y %I:%i %p'),book,returned, MATCH (full_name) AGAINST ('".$search."' IN BOOLEAN MODE) AS user_idnum FROM `checkout` WHERE MATCH (user_idnum) AGAINST ('".$search."' IN BOOLEAN MODE) ORDER BY `full_name` DESC"; $result = mysql_query($query); $num = mysql_num_rows($result);
-
The "double dollar signs" are called variable variables. http://www.php.net/manual/en/language.variables.variable.php
-
Can't be done using php alone. You're going to need javascript to change the values in a drop-down menu without reloading the page.
-
While is a loop. You're storing $path/$file back into $path each time it loops back over but not resetting $path back to it's original value. Which explains why it just keeps adding $file to the end of $path. To fix this, either reset $path or create another variable for storing the full path: Resetting path: $path = "$path/$file"; readfile($path); $path = "C:/pics"; Using new variable: $full_path = "$path/$file"; readfile($full_path); Or don't even set $path in the while loop and put the $path/$file directly in readfile: replace: $path = "$path/$file"; readfile($path); with: readfile("$path/$file");
-
Well, in your situation, the value of the checkbox is not being used. So it won't effect the results at all.
-
When a checkbox is unchecked, nothing is sent via POST. When a checkbox is checked, it's html value feild is sent. For setting a variable to yes or no if the checkbox is checked or unchecked, you can check it using the isset function. $c1 = (isset($_POST['c1'] ? "yes" : "no"); $c2 = (isset($_POST['c2'] ? "yes" : "no"); $c3 = (isset($_POST['c3'] ? "yes" : "no"); $c4 = (isset($_POST['c4'] ? "yes" : "no");
-
You're headed in the right direction. However, while is a loop, and even if there's a published post somewhere in the sql return, it will display "There are no published posts" in between the displayed info for the published posts whenever the loop encounters an unpublished post. You could achieve the right results by modifying your code in the if statement, or you can simply add " WHERE publish='Y' " to the end of your mysql query. With this query, it will only return the rows in which publish is Y.
-
Naming variable with a variable & setting variable with a variable
Showcase replied to Showcase's topic in PHP Coding Help
Thanks a ton. It worked exactly how I needed it to. -
I just started to learn php. Don't know if this one is possible, or if I'm approaching this the right way. I'm just learning by attempting to create something that reads an XML file, adds to it, then displays the final result. The XML file holds a playlist for a flash music player I made. This probably won't get used much, just thought I'd start learning php by designing this. I'm starting off with making the basic functionalities of the php. What I'm simply trying to do is set variables to inputted information using an html form. Now I know how to do that using "$_POST['song0name']" and 'song1URL' but the amount of songs being added is going to be "adjustable" I guess you can call it. So therefore, I'd like to use the do, while expression. The code I'm looking at looks something like this: $myVar = 0; do { $songname = echo ($songname); $myVar++; } while ($myVar < $songAmount); What I'm currently trying to do at the moment is to simply assign the value of $_POST['songname0'] to $songname, but using the number from $myVar for the "id" I guess it's called. Something like "$_POST['songname' . $myVar] but I can't seem to figure out how to make this work. I'm running into some problems as the code treating the value as a string rather than grabbing the value of the $_POST variable. I might just being going about this completely wrong, I'm not sure. Maybe someone here can give me some input, show me how to do it, or point me in the right direction. Thanks for any help.