PHP / MYSQL Question
#1

Hello,

I'm in the process of creating a UCP, I have it so I can enter my ingame details and it logs me in, I'm looking at doing a profile where I can view stats,

For example, If I want to show the IP, I get the table with mysql_query.

Is it something like this?

Код:
$rIP = mysql_query("SELECT * FROM Accounts WHERE Username = '" . $_SESSION['username'] . "'");
How would I get it to display the IP like var_dump?
Reply
#2

Fetch row
Reply
#3

I've got this, but getting errors?

Код:
	$result = mysql_query("SELECT * FROM Accounts WHERE Username = '" . $_SESSION['username'] . "'");
					while($row = mysql_fetch_array($result))
  					{
 						echo $row['IP'] "IP" " ";
						echo $row['Money'] "Cash" " ";
						echo  $row['BankMoney']"Bank" " ";   
  					}
Reply
#4

I've now got it so it shows the data, However it does show IP: "IP Here", Just "IPhere""Cash""Bank"

Any ideas on how I split it into lines so it's like

IP: "IPhere"
Cash: "Cash"
Bank: "Bank"
Reply
#5

use <br> ?
Reply
#6

First off, don't use mysql_* as it is deprecated (outdated) I recommend using PDO with prepared statements
Reply
#7

PHP код:
<?php
$result 
mysql_query("SELECT * FROM Accounts WHERE Username = '" $_SESSION['username'] . "'");
while(
$row mysql_fetch_array($result))
{
    echo 
$row['IP'] ." IP<br />"$row['Money'] ."Cash<br />"$row['BankMoney'] ."Bank <br />";   
}
?>
Reply
#8

Ohh... Nevermind.
Reply
#9

Quote:
Originally Posted by Mr_DjolE
Посмотреть сообщение
Why while() btw ?
mysql_fetch_row/array attempts to fetch rows from the resulting mysql set. While loops through the result set as long as there are rows. So if you have 3 rows the while loop will fetch $row 3 times.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)