1
fo-fo
displaying sql query results
  • 2005/4/21 16:04

  • fo-fo

  • Just popping in

  • Posts: 34

  • Since: 2005/4/13


in a block... how can I do that?

I would need to display a value associated with the logged-in user, yet the query username is different. so the second question is where to put the <{$xoops_uname}> tag to get relevant results?

thanks.

I guess this script queries the database

//connect to server with username and password
$connection = mysql_connect ("localhost","username", "password") or die ("Cannot make the connection");
//connect to database
$db = mysql_select_db ("test",$connection) or die ("Cannot connect to database");
//our SQL query
$sql_query = "SELECT * FROM test LIMIT 1";
//store the SQL query in the result variable
$result = mysql_query($sql_query);
if(mysql_num_rows($result))
{
//output as long as there are still available fields
while($row = mysql_fetch_row($result))
{
echo ("$row[3]");
echo (": $row[4]
");
}
}
//if no fields exist
else
{
echo "no values in the database";
}

?>

2
fo-fo
Re: displaying sql query results
  • 2005/4/21 22:00

  • fo-fo

  • Just popping in

  • Posts: 34

  • Since: 2005/4/13


my syntax is wrong or is this some kinda impossible thing.

I couldn't get results with it.

the edited block template looks like this -


<{foreach item=user from=$block.users}>
" valign="middle">



<{/foreach}>

<{$xoops_uname}>

mysql_connect("localhost", name, password);
$result = mysql(mydatabase, "SELECT quan FROM points WHERE
players.id=points.player_id AND <{$xoops_uname}>=players.first_name");
echo $result;
?>




the sql tables look like this -

players:
first_name...id
xxx..........1

points:
player_id....quan
1............100

so the result shoud be 100
where is the flaw?

Login

Who's Online

294 user(s) are online (233 user(s) are browsing Support Forums)


Members: 0


Guests: 294


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits