0

Hello,

im unsure how to fetch a database row that includes php,

i have a row in my database that displays a marquee saying 'welcome $username'

i have connected to the database but the php on page shows 'welcome $username'
how would i get it to state the username instaed of $username

$query = mysql_query("SELECT * FROM marquees");
$results = mysql_fetch_array($results);

$home = $results['home'];

echo $home;
5
Contributors
7
Replies
9
Views
5 Years
Discussion Span
Last Post by cgull
0
$query = mysql_query("SELECT * FROM marquees");
while($results = mysql_fetch_array($query)){
 
$home = $results['home'];
 
echo $home;
}

This will echo each result from your database query.

0

i have tried that but all i get is $username not the persons username.

0
echo 'welcome $username'; //gives the literal $username
//use double quotes to parse the variable:

echo "welcome $username";

Edited by diafol: n/a

0

im my database is

welcome $username

when the user logs in i want to be able to show the messge from database but with the users username in the place of $username

Edited by nats01282: n/a

0

You've got 'welcome $username' as data in your DB??

OKay, use str_replace().

Edited by diafol: n/a

0

You've got 'welcome $username' as data in your DB??

OKay, use str_replace().

Woow, guess who's back :D

0

As far as I understand, you have the word $username stored in your database?

Then it will print $username since it is just text.

You need the get the actual user name from the session.

Do I miss anything here?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.