Page 1 of 1

Counting members from MySQL

Posted: 24 Aug 2017, 09:42
by JanMolendijk
Chef i`m back hoping you could help me with this.
i think i need just one example then i can build a score-board for the members...

I have two examples where i want to make a count from both variables i would like to have a count-up +

Code: Select all

<?php 
  include('connection.php');

$result = $conn->query("SELECT COUNT(*) FROM `addon_message` WHERE friend_id='$users[id]'");
$row = $result->fetch_row();
echo ' ', $row[0];

?>
And:

Code: Select all

<?php 
  include('../connection.php');

$result = $conn->query("SELECT COUNT(*) FROM `member_access` WHERE user_id='$users[id]'");
$row = $result->fetch_row();
echo ' ', $row[0];

?>
Edit:
Strange i searching the whole day, but counters like + - * i can`t find them
But this one is also funny what i found & gonna use:

Code: Select all

<?php

$mystring = $row1[0];
$findme   = '8';
$pos = strpos($mystring, $findme);

// Note our use of ===.  Simply == would not work as expected
// because the position of 'a' was the 0th (first) character.
if ($pos === false) {
    echo "";
} else {
    echo "Active Member";
    echo "Great Score";
}
?>
Still i hope you have a answer for me (example).

Counting members from MySQL

Posted: 24 Aug 2017, 15:23
by Admin
Hello,
I didn't understand what counting you want to make.
If it is something with Up and Down, '+' or '-', like a voting, I have this script:
https://coursesweb.net/php-mysql/voting- ... pt-ajax_s2

Anyway, if you already have found something that you can use, it's ok.

Counting members from MySQL

Posted: 25 Aug 2017, 09:46
by JanMolendijk
Dear Admin i just looking for a simple sum up
1 + 1 = 2 strange i cant find it on the internet
or i use the wrong searching words

Counting members from MySQL

Posted: 25 Aug 2017, 09:51
by JanMolendijk
i found something like this but
now is my question how to use x - /

Code: Select all

<?php
$a = array($row[0], $row1[0]);
echo "sum(a) = " . array_sum($a) . "\n";

$b = array("a" => 1.2, "b" => 2.3, "c" => 3.4);
echo "sum(b) = " . array_sum($b) . "\n";
?>

Counting members from MySQL

Posted: 25 Aug 2017, 10:09
by JanMolendijk
Well i searching in dutch lang & now i found them all
But still thanks for supporting :)

Code: Select all

<?php
        $waarde1 = $row[0];
        $waarde2 = $row1[0];

        $optellen = $waarde1 + $waarde2;
        echo $optellen;
?>

Code: Select all

<?php
        $waarde1 = 10;
        $waarde2 = 5;

        $aftrekken = $waarde1 - $waarde2;
        echo $aftrekken; 
?>

Code: Select all

<?php
        $waarde1 = 10;
        $waarde2 = 5;

        $vermenigvuldigen = $waarde1 * $waarde2;
        echo $vermenigvuldigen; 
?>