zero_ZX Posted November 30, 2009 Share Posted November 30, 2009 Hi, Basically a user logs in and will be able to manage his or hers characters. Here's my code: <?php session_start(); // dBase file include "inc/config.php"; if (!$_SESSION["valid_user"]) { // User not logged in, redirect to login page Header("Location: login.php"); } // Member only content // Get the character ids from the wc_players table $result = mysql_query("SELECT character0, character1, character2, character3, character4, character5, character6, character7, character8, character9, character10, character11, character12, character13, character14, character15 FROM wc_players WHERE login ='$_SESSION[valid_user]'") or die(mysql_error()); //Print the character ids echo "<table border='1'>"; echo "<tr> <th>Character id:</th> </tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td>"; echo $row['character0']; echo "</td> <td>"; echo $row['character1']; echo "</td> <td>"; echo $row['character2']; echo "</td> <td>"; echo $row['character3']; echo "</td> <td>"; echo $row['character4']; echo "</td> <td>"; echo $row['character5']; echo "</td> </tr> <tr> <td>"; echo $row['character6']; echo "</td> <td>"; echo $row['character7']; echo "</td> <td>"; echo $row['character8']; echo "</td> <td>"; echo $row['character9']; echo "</td> <td>"; echo $row['character10']; echo "</td> </tr> <tr> <td>"; echo $row['character11']; echo "</td> <td>"; echo $row['character12']; echo "</td> <td>"; echo $row['character13']; echo "</td> <td>"; echo $row['character14']; echo "</td> <td>"; echo $row['character15']; echo "</td></tr>"; } echo "</table>"; // Display logout link echo "<p><a href=\"logout.php\">Click here to logout!</a></p>"; ?> Ye.. i know it's pure i only spent 30 mins Any way, In the echo part where it prints the character ids, is it possible to make a link to like characters.php?id=1,2,3etc.. ? If so, how would i do it? (if not, would could be an alternate?) Thanks a lot guys Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 30, 2009 Share Posted November 30, 2009 since your only selecting the characters from the database and no other information you can echo "<a href='characters.php?id=" . implode(',', array_values($row)) . "'>Characters</a><br />"; Quote Link to comment Share on other sites More sharing options...
zero_ZX Posted November 30, 2009 Author Share Posted November 30, 2009 Hi, Thanks for your help, but as one problem gets solved, another problem appears ^.^ I tried to enter echo "<tr><td>"; echo $row['character0']; echo "</td> <td>"; echo "<a href='characters.php?id=" . implode(',', array_values($row['character0'])) . "'>Manage</a><br />"; However this seems to give php errors.. But how else can I do this, as your solution makes the guy go and manage all his characters at the same time Quote Link to comment Share on other sites More sharing options...
lemmin Posted November 30, 2009 Share Posted November 30, 2009 I think rajivgonsalves took your request too literally. If you only want one character, then only print one of them: echo "<a href='characters.php?id=" . $row['character0'] . "'>".$row['character0']."</a><br />"; You have to do that for each line the way you are echoing them. You could do all of that output in a loop if you wanted. Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 30, 2009 Share Posted November 30, 2009 lol sorry about that I think I am become a computer following instruction sets displayed on the screen Quote Link to comment Share on other sites More sharing options...
zero_ZX Posted December 1, 2009 Author Share Posted December 1, 2009 I see, great.. thanks a lot guys 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.