Dynadot .com transfer sale, only $10.12 with coupon code DYNA12, available while supplies last, ends October 31, 2026.

How to "echo" .. PHP/Mysql

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
SpaceshipSpaceship
Watch
Impact
9
select count(*) from address where blenderp=1


I have spent 3 hours reading php tutorials and am not making any progress. even though I know this is pretty basic .. I cant get it

I know it is somehting like ..<?php
$Query = "select count(*) from address where blenderp=1"?>

Getting lost on how to echo that count

really appreciate some help
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Have you connected to the database?

Submitted the query?

Heres an example (which i've changed slightly) from http://au.php.net/manual/en/msql.examples-basic.php

Code:
<?php
/* Connecting, selecting database */
$link = msql_connect('localhost', 'username', 'password')
    or die('Could not connect : ' . msql_error($link));

msql_select_db('database', $link)
    or die('Could not select database');

/* Issue SQL query */
$Query = "select count(*) AS address_count from address where blenderp=1";
$result = msql_query($query, $link) or die('Query failed : ' . msql_error());

while ($row = msql_fetch_array($result)) {
 echo $row['address_count'];
}

/* Close connection */
msql_close($link);
?>
 
Last edited:
0
•••
Got it..thank You Music !
 
0
•••
This method is much more efficient.

This is easier on resources and faster:

PHP:
<?php
$dbname = 'xxx'; // db name 
$dbuser = 'xxx'; // db username 
$dbpass = 'xxx'; // db password 
$dbhost = 'localhost';     // db host, localhost should suffice. 
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error()); 
mysql_select_db($dbname, $conn) or die(mysql_error()); 
require('header.php');
$result = mysql_query('SELECT count(*) AS `address_count` FROM `address` WHERE `blenderp`=1') or die(mysql_error());
$result = mysql_result($result, 0, 0);
echo $result;
require('footer.php');

// you do not need to call mysql_cose(), it happens automagically at end of script.
?>
 
0
•••
Thanks for your codes.
Good sharing keep it up!
 
0
•••
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover

NamePros updates

Watched threads: your alert now keeps up with new replies
When you watch a thread, each new reply now updates your alert. Before, you got one alert and then nothing until you read the thread...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back