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/>";
  
        }
?>

Link to comment
Share on other sites

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'];
  
        }
?>

Link to comment
Share on other sites

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'];
  
        }


Link to comment
Share on other sites

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'];
  
        }
?>

Link to comment
Share on other sites

<?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
  
        }
?>

Link to comment
Share on other sites

<?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
  
        }
?>

 

Link to comment
Share on other sites

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

 

        }

?>

Link to comment
Share on other sites

<?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

Link to comment
Share on other sites

<?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
  
        }
?>

Link to comment
Share on other sites

<?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

}
?>

 

   

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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