PDA

View Full Version : How to display result of sql quire


MozyMac
08-21-2009, 11:29 AM
hello,

I have made quire to find number of users in a usergroup and code to display number, but when i add the code to my custom vb page it won't display it:



<?php

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'imamac'); // change this depending on your filename

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array(

);

// get special data templates from the datastore
$specialtemplates = array(

);

// pre-cache templates used by all actions
$globaltemplates = array(
'imamac',
);

// pre-cache templates used by specific actions
$actiontemplates = array(

);

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

// ################################################## #####################
// ######################## START MAIN SCRIPT ############################
// ################################################## #####################
$res = mysql_query("SELECT username FROM user WHERE usergroupid = 2") or die("Error: ".mysql_error());
$numRows = mysql_num_rows($res); // Here you get the number of rows returned
echo "There are currently $numRows users";
$navbits = array();
$navbits[$parent] = 'Im a Mac';

$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('imamac') . '");');




?>

Lynne
08-21-2009, 03:14 PM
Don't use echo. Assign the results text to a variable and spit the variable out in your template. What is in your template?

MozyMac
08-22-2009, 10:52 PM
Don't use echo. Assign the results text to a variable and spit the variable out in your template. What is in your template?

hmm it's name is imamac

thanks

MozyMac
08-24-2009, 07:48 AM
hmm lynne please help me :(

Thanks

Lynne
08-24-2009, 02:19 PM
I asked to see what was in your template but you haven't posted it.

Here's an example of what I mean by don't use echo. You have:
echo "There are currently $numRows users";

You should do it like this:
$myvar = "There are currently $numRows users";


And then put $myvar in your template.

MozyMac
08-26-2009, 12:10 AM
I asked to see what was in your template but you haven't posted it.

Here's an example of what I mean by don't use echo. You have:
echo "There are currently $numRows users";

You should do it like this:
$myvar = "There are currently $numRows users";


And then put $myvar in your template.

sorry for not replaying soon :(

Thanks for help :D