PHP / MYSQL Question -
acade - 30.01.2013
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?
Re: PHP / MYSQL Question -
RedCrossER - 30.01.2013
Fetch row
Re: PHP / MYSQL Question -
acade - 30.01.2013
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" " ";
}
Re: PHP / MYSQL Question -
acade - 30.01.2013
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"
Re: PHP / MYSQL Question -
KingHual - 31.01.2013
use <br> ?
Re: PHP / MYSQL Question -
Aldo. - 31.01.2013
First off, don't use mysql_* as it is deprecated (outdated) I recommend using PDO with prepared statements
Re: PHP / MYSQL Question -
Sinner - 31.01.2013
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 />";
}
?>
Re: PHP / MYSQL Question -
Djole1337 - 31.01.2013
Ohh... Nevermind.
Re: PHP / MYSQL Question -
Sinner - 31.01.2013
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.