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 6365219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:15:58+00:00 2026-05-25T00:15:58+00:00

I have a table in my MySQL database called Sponsors . This table has

  • 0

I have a table in my MySQL database called Sponsors.
This table has a two field. event and names. The field names is filled with different words. For example Pieter, Sam, Thomas. I would like to count the number of names in names.

How can I do this using PHP and SQL-requests. I though something like this…

$query = mysql_result(mysql_query("SELECT names FROM Sponsors WHERE id = '55'"));
$result = str_replace(',',' ', $query);
$total = count($result);

But this didn’t solve it…

EDIT

if(!empty($activiteiten))
    {
        foreach($activiteiten as $k => $v) 
            {
                $query = mysql_result(mysql_query('SELECT aanwezig FROM tblLeidingAgenda WHERE id = "'.$v["id"].'"),0');
                $result = str_replace(", ", " ", $query);
                $total = str_word_count($result);

                echo '<div class="lof-main-item">';
                echo '<img src="images/791902news3.jpg" title="Newsflash 2" height="300" width="900">           
                            <div class="lof-main-item-desc">
                                <h3><a target="_parent" title="Newsflash 2" href="#">'.$v["uur"].'</a></h3>
                        <p>'.$v["titel"].'</p>
                        ID: '.$v["id"].'
                    <form method="post" action="#">
                        <input type="submit" name="aanwezig" value="Ik ben aanwezig"/><br />
                        <input type="submit" name="afwezig" value="Ik ben afwezig"/><br />
                        <input type="submit" name="herinnering" value="Stuur herinnering"/><br />
                        <input type="text" name="id" value="'.$v["id"].'" />
                        Ik ben aanwezig ('.$total.'): '.$v["aanwezig"].'<br />
                        Ik ben afwezig: '.$v["afwezig"].'</form></div></div> ';
            }
    }
  • 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-25T00:15:58+00:00Added an answer on May 25, 2026 at 12:15 am

    Check the number of rows:

    $total = mysql_num_rows($result);
    

    PHP Manual (mysql_num_rows)

    Or SELECT COUNT(*) in the first place.

    Edit

    Oh nevermind, it looks like you’re storing a comma separated list right in a single cell. That’s a bad practice btw. You probably just need another MySQL table to store them properly. If you decide not to fix database schemat though this should work for you:

    $query = mysql_result(mysql_query("SELECT names FROM Sponsors WHERE id = '55'"));
    $result = explode(',',$query);
    $total = count($result);
    

    PHP Manual (explode)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MySQL database called bookfeather. It contains 56 tables. Each table has
I have an items table in my MySQL database with a DECIMAL(10,2) field called
Ok so i have a database table called requests with this structure mysql> desc
I have a user table in my mysql database that has a password column.
I am working in PHP/MySQL. I have a table in my database called hourly
I have a table called product_attributes in a MySQL Database. It consists of a
I have a table called products in a MySQL database. products looks some what
I have a mysql database table called POST . One of the fields is
I have a mysql database table called character with columns like name, strength, intelligence,
I have a field in a MySQL database called 'location' - it serves up

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.