Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7049045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:57:54+00:00 2026-05-28T02:57:54+00:00

I am coding the following, Im still very new to php so my coding

  • 0

I am coding the following, Im still very new to php so my coding is a bit rubbish, is there a better way of doing the following, ideally putting into one query or something, as this is the only way I know how to do it :-S .
Thanks 🙂

<?php
$query = ("SELECT COUNT(receivegasoilmailinglist) FROM     hqfjt_chronoforms_data_addupdatelead WHERE      receivegasoilmailinglist='yes'"); 
$result = mysql_query($query) or die(mysql_error()); 

$row = mysql_fetch_row($result); 
echo '<h1> gasoil :';
echo $row[0];  
echo '</h1>';
 ?>

<?php
$query2 = ("SELECT COUNT(receivedervmailinglist) FROM hqfjt_chronoforms_data_addupdatelead WHERE receivedervmailinglist='yes'"); 
 $result2 = mysql_query($query2) or die(mysql_error()); 

 $row2 = mysql_fetch_row($result2); 
 echo '<h1> derv :';
 echo $row2[0];  
 echo '</h1>';
 ?>

<?php
 $query3 = ("SELECT COUNT(receivekeromailinglist) FROM hqfjt_chronoforms_data_addupdatelead WHERE receivekeromailinglist='yes'"); 
 $result3 = mysql_query($query3) or die(mysql_error()); 

$row3 = mysql_fetch_row($result3); 
echo '<h1> kero :';
echo $row3[0];  
echo '</h1>';
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:57:54+00:00Added an answer on May 28, 2026 at 2:57 am

    If (and only if) either of these is true:

    • most of the rows in hqfjt_chronoforms_data_addupdatelead want some sort of newsletter
    • there are no indices on the receive*mailinglist fields

    you can save a lot of DB muscle by doing

    SELECT 
      sum(if(receivegasoilmailinglist='yes',1,0)) AS gasoil,
      sum(if(receivedervmailinglist='yes',1,0)) AS derv,
      sum(if(receivekeromailinglist='yes',1,0)) AS kero
    FROM hqfjt_chronoforms_data_addupdatelead;
    

    as this will traverse the table only once.

    For the rest of the job you use ofcourse

    $sql="... as above ...";
    $qry = mysql_query($sql) or die("Query failed: <br>SQL=$sql<br>Error=".mysql_error());
    $qry = mysql_fetch_row($qry);
    echo "<h1> gasoil: ".$qry[0]."</h1>";
    echo "<h1> derv: ".$qry[1]."</h1>";
    echo "<h1> kero: ".$qry[2]."</h1>";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The Zend Framework coding standard mentions the following: For files that contain only PHP
I'm still pretty new to Objective-C coding (as evidenced by this question) and I
In a question answer I find the following coding tip:- 2) simple lambdas with
My style of coding includes the following idiom: class Derived : public Base {
The following have been proposed for an upcoming C++ project. C++ Coding Standards, by
In general the SDLC has the following phase requirement gathering design coding testing deployment
Consider the following code (for simplicity, I did not follow any C# coding rules).
In my application I m using following coding convention to open my default screen
My problem stems from Emacs inserting the coding system headers into source files containing
( Updated a little ) I'm not very experienced with internationalization using PHP, it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.