Need help with coding this SQL code quickly..

Status
Not open for further replies.

TrueHabb

Member
Dec 20, 2011
117
8
What needs doing is that i want to change the "Taken by" and change it to "taken by {username}"
but the problem is if i type in "{username}" it will obv show the user who is onlien right now viewing the page.
so i need to make a sql or something to show the "username" from the database table colum.

the database table name is "vault" and the colum i need to get the username from is "Username"

can anybody help me tranform this picture below to the one beside it on the right had side..
sqqh6u.png

heres the code of what needs editing to show the username that won the item..
PHP:
<?php
 
$getPrizes = mysql_query("SELECT * FROM vault WHERE display = 1 ORDER BY Prize ASC");
while($Prizes = mysql_fetch_assoc($getPrizes))
{
 
    if($Prizes['Username'] == 'None')
    {
        $Status = "<font color='green'><strong>This items not been won yet!</strong></font>";
    } else {
        $Status = "<font color='red'><strong>Taken by {Username}</strong></font>";
    }
 
    echo '<tr><td><strong>' . $Prizes['Prize'] . '</strong></td><td>' . $Status . '</strong></td><td>' . $username . '</td></tr>';
}
 
?>
 

Weasel

👄 I'd intercept me
Nov 25, 2011
4,135
2,461
Replace {Username} with whatever you have as the name for that for $username or something. Could be I don't get you right...
 

Markshall

Русский Стандарт
Contributor
Dec 18, 2010
2,638
2,393
Would this not do? You'd have to change Username to whatever the username field is called in your table.

PHP:
<?php
 
$getPrizes = mysql_query("SELECT * FROM vault WHERE display = 1 ORDER BY Prize ASC");
while($Prizes = mysql_fetch_assoc($getPrizes))
{
 
    if($Prizes['Username'] == 'None')
    {
        $Status = "<font color='green'><strong>This items not been won yet!</strong></font>";
    } else {
        $Status = "<font color='red'><strong>Taken by " . $Prizes['Username'] . "</strong></font>";
    }
 
    echo '<tr><td><strong>' . $Prizes['Prize'] . '</strong></td><td>' . $Status . '</strong></td><td>' . $username . '</td></tr>';
}
 
?>
 

TrueHabb

Member
Dec 20, 2011
117
8
Would this not do? You'd have to change Username to whatever the username field is called in your table.

PHP:
<?php
 
$getPrizes = mysql_query("SELECT * FROM vault WHERE display = 1 ORDER BY Prize ASC");
while($Prizes = mysql_fetch_assoc($getPrizes))
{
 
    if($Prizes['Username'] == 'None')
    {
        $Status = "<font color='green'><strong>This items not been won yet!</strong></font>";
    } else {
        $Status = "<font color='red'><strong>Taken by " . $Prizes['Username'] . "</strong></font>";
    }
 
    echo '<tr><td><strong>' . $Prizes['Prize'] . '</strong></td><td>' . $Status . '</strong></td><td>' . $username . '</td></tr>';
}
 
?>
your my new legend? <3
 
Status
Not open for further replies.

Users who are viewing this thread

Top