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

  • Home
  • SEARCH
  • 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 9136623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:58:38+00:00 2026-06-17T08:58:38+00:00

I want to update a column in a table in mysql. Basically the column

  • 0

I want to update a column in a table in mysql. Basically the column is the flag for the entries of that db table.

The modification of the column is resetting all values to 0 and setting the desired row to 1, for this reason I have post.php file which looks like

<?php
require_once('class.uuid.php');

$connection = mysql_connect("---logindetailshere---");
$db = mysql_select_db("---dbnamehere---",$connection);

switch($_REQUEST['action']){
    case ...
        break;
    case ...
            break;
    case 'changeDisp':
        changeDisp($_REQUEST['uid']);
        break;
}

mysql_close($connection);

...

function changeDisp($uid){
    global $connection, $db;
    $q_string = "UPDATE Questions SET Displayed = 0";
    $query = mysql_query($q_string,$connection) or die( sendError(mysql_error() . '<br/><br/>' . $q_string) );
    $q_string = "UPDATE Questions SET Displayed = 1 WHERE Uid='${uid}'";
    $query = mysql_query($q_string,$connection) or die( sendError(mysql_error() . '<br/><br/>' . $q_string) );
}

?>

on the webpage I display the items and radiobuttons next to the items, the purpose is to select the radiobuttons and post to set the flag 1 for the selected item, for this reason I have a item.php file

    <?php
        $i = 1;
        foreach ($qitem as &$q) {
            $options = explode(";", $q["Options"]);
            $displayed = '';
            if ($q["Displayed"] == 1) { $displayed='checked="yes"'; }

            echo("<div class='item' name='".$q["iUid"]."'>");
            echo("<div class='count'>".$i.".</div>");
            echo ("<div class='radio'><input type='radio' onclick='changeDisp(&#34;".$q["Uid"]."&#34;)' name='disp' ".$displayed."></div>");
            echo("<div class='left'>");
            echo("<h4>".$q["Value"]."</h4>");
            echo("<div class='details'>Typ: ".$q["Type"]."</div>");
            echo("<div class='details'>Skala: ".$options[0]." / ".$options[1]."</div>");
            echo("</div>");
            echo("</div>");
            $i++;
        }   
    ?>

here I am using radiobuttons to select the related item, I checked the unique id values using firebug the values are fine, I just want to click on any radiobutton and want to trigger the onclick=changeDisp() function.

I have no idea why the page doesn’t reload itself and change the selected flag to 1. Could you please help me to solve this problem?

Thanks in advance.

  • 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-17T08:58:38+00:00Added an answer on June 17, 2026 at 8:58 am

    You cannot use an onclick function to call php function without going there with a javascript, jQuery or ajax call. You could create an ajax script to call the post.php From the item.php page and return the results to you.

    Here is an example of creating the function you want. This assumes that $uid is coming from a radio button and not an actual user input. If the user can directly input something you need to use a prepared statment

     function changeDisp($uid)
    {
    $Mysqli = new mysqli(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME);
        if ($Mysqli->connect_errno)
        {
            echo "Failed to connect to MySQL: (" . $Mysqli->connect_errno . ") " . $Mysqli->connect_error;
            $Mysqli->close();
        }           
        $query = "UPDATE Questions SET Displayed = 1 WHERE Uid='".$uid."'";     
        $update = $Mysqli->query($query);
        if($update)
        {
            return true;
        }
        return false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good morning all, i want to create an event in MySQL that will UPDATE
I want to update a specific column for all rows in a table in
I want to update the values of one column in a table from '0'
I want to Update Column of a Table where ColumnName will be DropDown.SelectedValue. Example:
I want to update a column in a table making a join on other
I want to perform an update on all the rows in an XML column
Iam using a Java Swing Application to Update a column in Mysql table. Here
I'm doing a mysql table and i have one column that has current timestamp
I've got a mysql table column that acts as a counter (int). Each time
I am using node-mysql to update a MySQL database table from node.js. I want

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.