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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:27:31+00:00 2026-06-09T15:27:31+00:00

I have a bit difficulty to explain this question in a simple way, so

  • 0

I have a bit difficulty to explain this question in a simple way, so explanation will be long.
User can vote if comment is useful or not (simple yes or no), and when he do this, his vote is send into data base -> table ‘user_vote’.

Table user_vote have two columns – user_id and container. Every user have only one row in this table. When he cast new vote, field container is updated. For example, user vote on a comment with id 205 and he voted yes, and on a comment with id 300 he voted no.
Table user_vote will look like this:

user_id->111;

container->205-yes,300-no

This is working fine, until this code here, where I need to check if user had voted on particular comment. Code here is working partially – problem is following:

Is user had voted 3 time and if id of the comment matches $split[0] it will one time write $text and it will produce 2 set of buttons, and if id of the comment is not matched it will produce 3 set of buttons (part after elseif is working correctly).

What am I doing wrong and how can I write code in correct way?

<div class="zuta_strana_komentar_korisno" data-id="<?php echo $cmm['id_comment'] ?>">
    <?php if(isset($glas) && !empty($glas)) : 
    $br = explode(',', $glas->container);
    foreach($br as $br) :                                  
    $split = explode('-', $br);
    if($split[0] == $cmm['id_comment']) : ?>
    <?php 
    if($split[1] == 'yes') :
    $text = 'koristan.';
    else :
    $text = 'nekoristan.';
    endif;
    ?>
    <p>Ovaj komentar vam je bio <?php echo $text ?></p>
    <?php else :?>
    <p>Da li vam je ovaj komentar bio od pomoći?</p>
    <button role="yes">Da</button><button role="no">Ne</button>
    <?php 
    endif;
    endforeach;             
    elseif($this->session->userdata('is_logged_in') == TRUE && empty($glas)) : ?>
    <p>Da li vam je ovaj komentar bio od pomoći?</p>
    <button role="yes">Da</button><button role="no">Ne</button>
    <?php endif ?>
    </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-06-09T15:27:33+00:00Added an answer on June 9, 2026 at 3:27 pm

    You are fundamentally designing your database improperly. Good database design does not store information using comma separated lists in fields. By storing the data in the comma separated lists, you are essentially nullifying all the database’s querying functionalities. Use tables, that’s why you’re given them!

    I suggest creating tables: users, comments, and votes

    users table contains id, username… among other fields

    comments table contains id, body, user_id…among other fields

    votes table contains id, comment_id, user_id, yes_or_no… among other fields

    Then get a handle on how to properly use SQL Joins

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

Sidebar

Related Questions

The question is a bit difficult to explain, but I will try. I have
I am having a bit of difficulty with this current code I have set
This will be a bit difficult to explain but I will try my best.
I'll try to explain this the best I can. I'm having quite a bit
This might be a bit difficult to explain but I have two columns in
I have this problem which i find a bit difficult to explain but I
This is a bit difficult to explain, so I'll try to give a simple
This one is a bit tricky to explain. I have a usercontrol with some
Can someone explain ARM bit-shifts to me like I'm five? I have a very
I have a question regarding how initialization vector works on cryptography. I have bit

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.