Jump to content


Photo

Display Query issue.


  • Please log in to reply
3 replies to this topic

#1 idos

idos
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 25 August 2006 - 06:20 PM

I can't display the output from a query function..

<?php
include 'config.php'
?>
<?php

if(isset($_COOKIE['ID_my_site']))
{
$username = $_COOKIE['ID_my_site'];
}
else
{
echo 'du er ikke logget inn';
}


$con = mysql_connect($host,$dbuser,$dbpass);




if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("klatrereg", $con);

$result = mysql_query( $sql = 'SELECT SUM(score) FROM ruter WHERE Navn= \'idar\' ORDER BY `Grad` DESC LIMIT 0,20 ');

// here i need some code to display the SUM(score)


mysql_close($con);
?>


I have tried several things but none seem to work.. .HELP :P

#2 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 25 August 2006 - 06:37 PM

Try:

<?php
include 'config.php'
?>
<?php

if(isset($_COOKIE['ID_my_site']))
{
$username = $_COOKIE['ID_my_site'];
}
else
{
echo 'du er ikke logget inn';
}


$con = mysql_connect($host,$dbuser,$dbpass);




if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("klatrereg", $con);

$result = mysql_query( $sql = 'SELECT SUM(score) FROM ruter WHERE Navn= \'idar\' ORDER BY `Grad` DESC LIMIT 0,20 ');
$score = mysql_fetch_row($result);
echo "$score";


mysql_close($con);
?>


#3 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 25 August 2006 - 06:39 PM

$result = mysql_query( $sql = 'SELECT SUM(score) as 'scoretotal' FROM ruter WHERE Navn= \'idar\' ORDER BY `Grad` DESC LIMIT 0,20 ');
$row=mysql_fetch_array($result);
echo $row['scoretotal'];


Think that should do the trick
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#4 idos

idos
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 25 August 2006 - 07:54 PM

Tnx ..  ;D

This worked:

$result = mysql_query( $sql = 'SELECT SUM(score) as scoretotal FROM ruter WHERE Navn= \'idar\' ORDER BY `Grad` DESC LIMIT 0,20 ');
$row=mysql_fetch_array($result);
echo $row['scoretotal'];





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users