Jump to content

Archived

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

idos

Display Query issue.

Recommended Posts

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

[quote][code=php:0]
<?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);
?>[/code][/quote]

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

Share this post


Link to post
Share on other sites
Try:

[code]
<?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);
?>
[/code]

Share this post


Link to post
Share on other sites
[code]$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'];[/code]


Think that should do the trick

Share this post


Link to post
Share on other sites
Tnx ..  ;D

This worked:

[code]$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'];[/code]

Share this post


Link to post
Share on other sites

×

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.