Jump to content

[SOLVED] display mysql table data


Jiraiya

Recommended Posts

try using this code....

 

<?php

$username = $_COOKIE['ID_my_site'] //this is the session variable containing the username of the person logged in.
$sql = mysql_query("SELECT username,skill FROM members WHERE username = '$username'") or die(mysql_error());

   while($row = mysql_fetch_array($sql)) {

                    echo $row['username']."<br/>";
                    echo $row['skill']."<br/>";
  
        }
?>

are you using an include on player.php?? if so, what is the name of that file

 

try using teh code below...

 

<?php

$sql = mysql_query("SELECT username,skill FROM members WHERE username = 'tester'") or die(mysql_error());

   while($row = mysql_fetch_array($sql)) {

                    echo $row['skill'];
  
        }
?>

you need to make the connection to your db first, what is the name of the database and what is the name of the table inside the database??? take a look at the code properly and look to see if everything is referenced with the right name..

 

username

password

table name

database name

 

etc

 

<?php

// Connects to your Database
mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("members") or die(mysql_error());

$sql = mysql_query("SELECT username,skill FROM members WHERE username = 'tester'") or die(mysql_error());

   while($row = mysql_fetch_array($sql)) {

                    echo $row['skill'];
  
        }


try this code and let me know...

 

 

<?php

// Connects to your Database
mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("members") or die(mysql_error());

$sql = mysql_query("SELECT skill FROM users WHERE username = 'tester'") or die(mysql_error());

   while($row = mysql_fetch_array($sql)) {

                    echo $row['skill'];
  
        }
?>

<?php
$sql = mysql_query("SELECT skill FROM users WHERE username = 'tester'") or die(mysql_error());

   while($row = mysql_fetch_array($sql)) {

                    echo "Username:".$row['username'];
                    echo "Skill:".$row['skill'];
                    // Then just carry on
  
        }
?>

<?php
$username = $_COOKIE['ID_my_site']; //this is the session variable containing the username of the person logged in.
$sql = mysql_query("SELECT username,skill FROM members WHERE username = '$username'") or die(mysql_error());

   while($row = mysql_fetch_array($sql)) {

                    echo "Username:".$row['username'];
                    echo "Skill:".$row['skill'];
                    // Then just carry on
  
        }
?>

 

i replaced the last code with the the one above but now the page is blank ??? ???

 

 

this is the code i got going

 

 

 

Name:

<?php

echo $_COOKIE['ID_my_site'];

?>

<br>

 

 

<?php

 

// Connects to your Database

mysql_connect("localhost", "username", "password") or die(mysql_error());

mysql_select_db("members") or die(mysql_error());

 

$username = $_COOKIE['ID_my_site'] //this is the session variable containing the username of the person logged in.

$sql = mysql_query("SELECT username,skill FROM members WHERE username = '$username'") or die(mysql_error());

 

  while($row = mysql_fetch_array($sql)) {

 

                    echo "Username:".$row['username'];

echo "Level:".$row['level'];

                    echo "Skill:".$row['skill'];

                    // Then just carry on

 

        }

?>

<?php
$username = $_COOKIE['ID_my_site']; 
$sql = mysql_query("SELECT username,skill FROM members WHERE username = '$username'") or die(mysql_error());

   while($row = mysql_fetch_array($sql)) {

                    echo "Username:".$row['username'];
                    echo "Skill:".$row['skill'];
                    // Then just carry on
  
        }
?>

 

realised i missed a ; out try that

<?php
$username = $_COOKIE['ID_my_site']; 
$sql = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());

   while($row = mysql_fetch_array($sql)) {

                    echo "Username:".$row['username'];
                    echo "Skill:".$row['skill'];
                    // Then just carry on
  
        }
?>

<?php
$username = $_COOKIE['ID_my_site']; 
$sql = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());

   while($row = mysql_fetch_array($sql)) {

                    echo "Username:".$row['username']."<br/>";
                    echo "Skill:".$row['skill']."<br/>";
                    // Then just carry on

}
?>

 

   

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.