Jump to content

Zoroaster

Members
  • Posts

    25
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Zoroaster's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks Mark Baker. I forgot to change the money column to INT. Silly me
  2. Hey guys. I've made a list of the usernames with their amount of money next to them. I've also managed to make the ones with money appear at the top and the ones without money will appear at the bottom. However, the players aren't ordered by the value of money, only the fact that they have money. If you have any idea of how I can make them appear in the order of the value of their money, that'd be great. Here's the code: <?php session_start(); if(!session_is_registered(myusername)) { header("location:index.php"); } echo '<html>'; echo '<body>'; echo '<br>'; echo '<br>'; echo '<br>'; echo '<table border="2" bgcolor="#339933" align="center" width="66%"> '; echo '<tr>'; echo '<b><center>Username And Money</b></center>'; echo '</tr>'; echo '</table>'; echo '</body>'; echo '</html>'; $connect = mysql_connect("localhost","zoroaste","***"); mysql_select_db("zoroaste_test1"); $sql4 = "SELECT * FROM Login ORDER BY `Login`.`money` DESC LIMIT 0 , 300 "; $query = mysql_query($sql4); while($row = mysql_fetch_array($query)) { $uusername = $row['username']; $money = $row['money']; $c = array($money => $uusername); foreach ($c as $key1 => $username1){ echo '<html>'; echo '<body bgcolor="#0000CC">'; echo '<table border="2" bgcolor="#339933" align="center" width="66%">'; echo '<tr>'; echo '<td width="50%">'; echo '<center>'; echo $username1; echo '</center>'; echo '<br />'; echo '</td>'; echo '<td>'; echo '<center>'; echo $money; echo '</center>'; echo '<br />'; echo '</td>'; echo '</tr>'; echo '</table>'; echo '</body>'; echo '</html>'; } } ?>
  3. Great, thanks. Straight to the point - that's how I like it Thank you.
  4. Ok look. echo "$uusername" is one variable of course, and that one variable shows all the usernames. The output is: "pieZoroastertesttertblobBoldheadJoeHallomerdboofergunnar" What I'd want it to be would be: " pie Zoroaster test tert blob Boldhead Joe Hallo merd boofer gunnar " But how can I set a line break between the usernames when all the usernames are in the one and same variable?
  5. Yeah but that would just link all the usernames as one link and also just add a break under or above all the usernames. Not between the usernames.
  6. <?php session_start(); if(!session_is_registered(myusername)) { header("location:index.php"); } $connect = mysql_connect("localhost","zoroaste","***"); mysql_select_db("zoroaste_test1"); $sql4 = "SELECT * FROM Login"; $query = mysql_query($sql4); while($row = mysql_fetch_array($query)) {$uusername = $row['username']; echo "$uusername";} ?> Thanks, that worked! However, the output is the usernames all next to eachother without spaces. Any idea how I could put in a break line between them? And also make their names a link?
  7. No that displayed only the last user (the one with the highest ID)
  8. Here, take a look at the whole code. Here I did what I planned to do. And it works, with no troubles at all. However, now I want to try and edit this code to show ALL the usernames in the database, not just the one the person is logged in to. Take a look at the code and see if you come up with an idea. <?php session_start(); if(!session_is_registered(myusername)) { header("location:index.php"); } $username = $_SESSION['myusername']; $moneybutton = $_POST['moneybutton']; $connect = mysql_connect("localhost","zoroaste","***"); mysql_select_db("zoroaste_test1"); $sql4 = "SELECT * FROM Login WHERE username LIKE '$username';"; $query = mysql_query($sql4); while($row = mysql_fetch_array($query)) { $uusername = $row['username']; $money= $row['money']; } echo "<br><br><b>Hello $uusername </b><br>"; echo "<b>You have: $money coins!</b>"; if ($moneybutton) { $rand = (rand(2,10)); $newamount = $money + $rand; mysql_query("UPDATE Login SET money = $newamount WHERE username LIKE '$username'"); echo "<br><br>congratulations you found $rand coins!"; } ?> <html> <body bgcolor="#000066"> <br> <br> <b><center>THIS IS THE MAIN PAGE! WELCOME!</b> <br> <br <form action='page1.php' method='post'> <input type='submit' name='moneybutton' value='Click this button to search for coins!'> </form> </body> </html>
  9. Hi. I've been struggling with this for a while, sorry but I'll have to come ask for your help once again. I'm trying to show all the registered usernames from the database on my site, I've only managed to make it show the username you're logged in on, not every username. Thanks.
  10. <? $host = "localhost"; $username = "zoroaste"; $password = "****"; $db_name = "zoroaste_test1"; $tbl_name = "Login"; mysql_connect($host, $username, $password) or die("Failed to connect to mysql!"); mysql_select_db($db_name) or die ("Failed to connect to mysql!"); $myusername = $_POST['myusername']; $mypassword = $_POST['mypassword']; $sql = "SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result = mysql_query($sql); $count = mysql_num_rows($result); if($count==1){ session_register("myusername"); session_register("mypassword"); header("location:login_success.php"); } else { echo "Wrong Username or Password"; } ?> Alright this is the whole checklogin.php file. I'm still confused. Where am I specifying myusername and what am i specifying it to? I know that it's deprecated, but lets just look away from that. I'm trying to make a list of all the registered members post itself on the site. And this is confusing me. I can only manage to make it show the user you're logged in to.
  11. Ok, I checked my checklogin.php file and I found this: $count = mysql_num_rows($result); if($count==1){ session_register("myusername"); session_register("mypassword"); header("location:login_success.php"); } Is that where I specified it?
  12. So even though "myusername" was specified in a DIFFERENT php file it still finds it? I certainly havent specified "myusername" in the php file i took the code out from. It's just the code I paste in to make users not be able to go to the pages if they are not logged in.
  13. So is "myusername" something I have specified?if so where? Cos I've tried editing it to 'username' but that doesn't work... For some reason it has to be "myusername"
  14. I'm not a very good php programmer, so can you tell me what that means?
  15. I've viewed so many different tutorials etc. and made so many codes that I actually now don't understand some of my code. Please do take a look: <?php session_start(); if(!session_is_registered(myusername)) { header("location:index.php"); } The thing that confuses me is "myusername" Where the hell is it coming from? I can't remember why I put it there when I first did. And now it's confusing me to pieces! It's nothing in the database, it's not a variable, and it's not the name of some html stuff either. So what is it?? Thanks guys.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.