MySql & Checkbox

Bonjour,
Quelqu'un pourrait-il m'aider ?
J'ai une chaine de caractère (2,3,5) renvoyée sur
ma base de données à partir de champs checkbox de mon
formulaire.
J'aimerais afficher sur une page les étiquettes (label)
correspondant à ces valeurs (value).
Je n'y arrive pas avec un switch, des cases et des echo. Dans
ce cas, seulement l'équivalent du premier caractère est
renvoyée; les autres sont simplement ignorés.
Quelqu'un pourrait-il me dire comment procéder ?
Merci.

I have the following code that generates all the checkboxes for rows coming from my Discipline table
                              <?php
                                       $discipline_set = finddisciplines();
                                    while ($dislist = mysql_fetch_assoc ($discipline_set)) {
                                        echo '<input type="checkbox" '.$dislist['dis_id']. '"'; ?>
                                        <?php if ((isset ($_POST ['dis_id']) || ($dislist['dis_id']) == $url_eventid ['dis_id'])) {
                                            ?>checked="checked" <?php } ?>
                                            <?php echo '>'.$dislist['dis_description'].'<br />';
                                    } ?>
However, I understand I need to allocate a name to each row from my table to then $_POST them into the table called EventDisc, each checkbox would generate a separate row in EventDisc.  This is as far as I have got so far and not sure how to make the next steps.

Similar Messages

  • Checkbox to filter mysql query

    SO I have created a combined search and results page which works great.  In the database I have a boolean variable that determines if the record is active.  I want to include a checkbox on the search form that will return only the active records.  Struggling a little.  Here's the code:
    <?php require_once('Connections/testmypms.php'); ?>
    <?php
    $currentPage = $_SERVER["PHP_SELF"];
    $maxRows_demographics = 10;
    $pageNum_demographics = 0;
    if (isset($_GET['pageNum_demographics'])) {
      $pageNum_demographics = $_GET['pageNum_demographics'];
    $startRow_demographics = $pageNum_demographics * $maxRows_demographics;
    $vardemid_demographics = "%";
    if (isset($_POST['schDemID'])) {
      $vardemid_demographics = (get_magic_quotes_gpc()) ? $_POST['schDemID'] : addslashes($_POST['schDemID']);
    $vardemfirstname_demographics = "%";
    if (isset($_POST['schDemFirstname'])) {
      $vardemfirstname_demographics = (get_magic_quotes_gpc()) ? $_POST['schDemFirstname'] : addslashes($_POST['schDemFirstname']);
    $vardemsurname_demographics = "%";
    if (isset($_POST['schDemSurname'])) {
      $vardemsurname_demographics = (get_magic_quotes_gpc()) ? $_POST['schDemSurname'] : addslashes($_POST['schDemSurname']);
    $vardemactive_demographics = "1";
    if (isset($_POST['schActive'])) {
      $vardemactive_demographics = (get_magic_quotes_gpc()) ? $_POST['schActive'] : addslashes($_POST['schActive']);
    mysql_select_db($database_testmypms, $testmypms);
    $query_demographics = sprintf("SELECT demographics.px_id, demographics.firstname, demographics.surname, demographics.address1, demographics.address2, demographics.town, demographics.postcode, title.title, demographics.active FROM demographics, title WHERE demographics.FK_title_id = title.title_id AND demographics.px_id LIKE '%s%%' AND demographics.firstname LIKE '%s%%'  AND demographics.surname LIKE '%s%%' AND demographics.active='%s' ORDER BY demographics.surname, demographics.firstname", $vardemid_demographics,$vardemfirstname_demographics,$vardemsurname_demographics,$vardema ctive_demographics);
    $query_limit_demographics = sprintf("%s LIMIT %d, %d", $query_demographics, $startRow_demographics, $maxRows_demographics);
    $demographics = mysql_query($query_limit_demographics, $testmypms) or die(mysql_error());
    $row_demographics = mysql_fetch_assoc($demographics);
    if (isset($_GET['totalRows_demographics'])) {
      $totalRows_demographics = $_GET['totalRows_demographics'];
    } else {
      $all_demographics = mysql_query($query_demographics);
      $totalRows_demographics = mysql_num_rows($all_demographics);
    $totalPages_demographics = ceil($totalRows_demographics/$maxRows_demographics)-1;
    $queryString_demographics = "";
    if (!empty($_SERVER['QUERY_STRING'])) {
      $params = explode("&", $_SERVER['QUERY_STRING']);
      $newParams = array();
      foreach ($params as $param) {
        if (stristr($param, "pageNum_demographics") == false &&
            stristr($param, "totalRows_demographics") == false) {
          array_push($newParams, $param);
      if (count($newParams) != 0) {
        $queryString_demographics = "&" . htmlentities(implode("&", $newParams));
    $queryString_demographics = sprintf("&totalRows_demographics=%d%s", $totalRows_demographics, $queryString_demographics);
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Search</title>
    </head>
    <body>
    <p>Patient Search</p>
    <form action="" method="post" name="schDem" id="schDem">
      <table border="1" cellspacing="1" cellpadding="5">
        <tr>
          <td>ID</td>
          <td><input name="schDemID" type="text" id="schDemID"></td>
          <td> </td>
        </tr>
        <tr>
          <td>Firstname</td>
          <td><input name="schDemFirstname" type="text" id="schDemFirstname"></td>
          <td> </td>
        </tr>
        <tr>
          <td>Surname</td>
          <td><input name="schDemSurname" type="text" id="schDemSurname"></td>
          <td>Show active only
          <input name="schActive" type="checkbox" id="schActive" value="0" checked></td>
        </tr>
        <tr>
          <td> </td>
          <td><input name="Search" type="submit" id="Search" value="Search"></td>
          <td> </td>
        </tr>
      </table>
    </form>
    <p> <a href="<?php printf("%s?pageNum_demographics=%d%s", $currentPage, max(0, $pageNum_demographics - 1), $queryString_demographics); ?>">Previous</a> <a href="<?php printf("%s?pageNum_demographics=%d%s", $currentPage, min($totalPages_demographics, $pageNum_demographics + 1), $queryString_demographics); ?>">Next</a></p>
    <table border="1">
      <tr>
        <td>px_id</td>
        <td>title</td>
        <td>firstname</td>
        <td>surname</td>
        <td>address1</td>
        <td>address2</td>
        <td>town</td>
        <td>postcode</td>
      </tr>
      <?php do { ?>
      <tr>
        <td><a href="main.php?pxID=<?php echo $row_demographics['px_id']; ?>"><?php echo $row_demographics['px_id']; ?></a></td>
        <td><?php echo $row_demographics['title']; ?></td>
        <td><?php echo $row_demographics['firstname']; ?></td>
        <td><?php echo $row_demographics['surname']; ?></td>
        <td><?php echo $row_demographics['address1']; ?></td>
        <td><?php echo $row_demographics['address2']; ?></td>
        <td><?php echo $row_demographics['town']; ?></td>
        <td><?php echo $row_demographics['postcode']; ?></td>
      </tr>
      <?php } while ($row_demographics = mysql_fetch_assoc($demographics)); ?>
    </table>
    </body>
    </html>
    <?php
    mysql_free_result($demographics);
    ?>
    Any suggestions would be great
    Thanks

    Just prior to this line:
    mysql_select_db($database_testmypms, $testmypms);
    Add this
    echo $vardemactive_demographics;
    Then execute and try with the checkbox checked and unchecked. Are the values displayed what you expect under both conditions?
    Next, you are setting the variable default to a string value
    $vardemactive_demographics = "1";
    Boolean values are numeric in MySQL so it should be
    $vardemactive_demographics = 1;

  • Dynamic checkbox - displaying from mysql database and inserting after selection

    I have a many to many relationship between Students and Modules and I created another table called StudentModules which will hold StudentID and ModuleID.  Since it is a many to many, one students can study many modules..
    I am trying to create a page where the user will select the modules he or she will be taking from a web page with checkboxes (The Modules will be coming from the Modules table).  The selection will then be inserted into StudentModules.  Can anyone guide me to a tutorial which can help me?  I can pick up the StudentID either from session or url variable but having problems with checkboxes.  I am using php mysql and Dreamweaver.

    Hi Bregent,
    Thanks for your suggestions.  This is what I have for the moment.
    http://p4uluv.brinkster.net/cfsl/moduleselection.php
    and the piece of coding for my checkbox are:
    <?php do { ?>
          <input name="checks" type="checkbox" id="checks" value="<?php echo $row_rsModules['ModulesID']; ?>" <?php if (!(strcmp($row_rsModules['ModulesID'],"True"))) {echo "checked=\"checked\"";} ?>>
          <label for="checks"><?php echo $row_rsModules['ModulesName']; ?></label>
          <?php } while ($row_rsModules = mysql_fetch_assoc($rsModules)); ?>
    I am hoping once it is checked, it will pick up the ModulesID.  I am now in the process of creating another page that will pick up the moduleID..

  • PHP/MySQL multiple checkbox insert

    Hi All,
    I am creating an order samples page where people can select up to 3 samples.
    The selected checkboxes will go into a database.
    How do I insert the selected checkboxes values into a database? I only managed to insert 1 value.
    Here are the checkboxes:
                             <label><input type="checkbox" name="samples_" value="sample1" id="samples_1">sample1</label>
                             <label><input type="checkbox" name="samples_" value="sample2" id="samples_2">sample2</label>
                              <label><input type="checkbox" name="samples_" value="sample3" id="samples_3">sample3</label>
                              <label><input type="checkbox" name="samples_" value="sample4"  id="samples_4">sample4</label>
                              <label><input type="checkbox" name="samples_" value="sample5" id="samples_5">sample5</label>
                              <label><input type="checkbox" name="samples_" value="sample6"  id="samples_6">sample6</label>
    Any help or advice is much appreciated
    Thanks

    Hi All,
    I am creating an order samples page where people can select up to 3 samples.
    The selected checkboxes will go into a database.
    How do I insert the selected checkboxes values into a database? I only managed to insert 1 value.
    Here are the checkboxes:
                             <label><input type="checkbox" name="samples_" value="sample1" id="samples_1">sample1</label>
                             <label><input type="checkbox" name="samples_" value="sample2" id="samples_2">sample2</label>
                              <label><input type="checkbox" name="samples_" value="sample3" id="samples_3">sample3</label>
                              <label><input type="checkbox" name="samples_" value="sample4"  id="samples_4">sample4</label>
                              <label><input type="checkbox" name="samples_" value="sample5" id="samples_5">sample5</label>
                              <label><input type="checkbox" name="samples_" value="sample6"  id="samples_6">sample6</label>
    Any help or advice is much appreciated
    Thanks

  • Checkbox group and Java Studio Creator 2 EA 2 - MySQL 5.0.16

    Hi folks, there is a bug while I try to use the checkbox group linked with a table:
    1. I create a form
    2. I put some fields in it
    3. I put a button that saves the data
    I run the application and everything works for the moment
    4.I put a checkbox group and the IDE creates automatically a checkboxGroup1DefaultOptions
    I run the application and everything works.
    5. I link the checkbox group with a table. The table has several fields, Strings and BIGINT(20)
    6. The IDE creates automatically a Long converter (checkboxGroup1Converter - javax.faces.convert.Long) because I use the BIGINT type to hold my primary key
    I run the application and everything works (I can still update my data except the checkbox group as the code doesn't exist yet)
    7. I'll add the code ion the prerender to read the table and reflect the selection of the users on the checkbox group. Check the checkbox group description inside this tutorial http://developers.sun.com/prodtech/javatools/jscreator/ea/jsc2/learning/tutorials/about_components.html
    ArrayList mySelectedXXX = new ArrayList();
    mySelectedXXX.clear();
    while (resultSet.next()) {
    mySelectedXXX.add(new Long(resultSet.getLong("id_XXX")));
    checkboxGroup1.setSelected(mySelectedXXX);
    .....8. I run the application
    9. The checkbox group reflects the content of the table
    9 I click on the save button
    try {
                XXXByIDDataProvider.commitChanges();
                info("Changes saved.") ;
            } catch (Exception ex) {
                log("Error Description", ex);
                error(ex.getMessage());
            return null;10. I receive the following exception. Here is the code that raises this exception.
    public LongConverter getCheckboxGroup1Converter() {
            return checkboxGroup1Converter;
    Does anyone has an idea about the reason of the bug. I tried to debug line by line but the ConversionUtilities.java does to seem to be reachable by the debugger.
    I think that the assignement in the prerender method could be the cause of the problem: ...............
    while (resultSet.next()) {
    mySelectedXXX.add(new Long(resultSet.getLong("id_XXX")));
    checkboxGroup1.setSelected(mySelectedXXX);
    =====================================================
    Exception Handler
    Description: An unhandled exception occurred during the execution of the web application. Please review the following stack trace for more information regarding the error.
    Exception Details: java.lang.NullPointerException
      null
    Possible Source of Error:
       Class Name: com.sun.web.ui.util.ConversionUtilities
       File Name: ConversionUtilities.java
       Method Name: convertValueToList
       Line Number: 421
    Source not available. Information regarding the location of the exception can be identified using the exception stack trace below.
    Stack Trace:
    com.sun.web.ui.util.ConversionUtilities.convertValueToList(ConversionUtilities.java:421)
    com.sun.web.ui.component.Selector.getConvertedValue(Selector.java:143)
    com.sun.web.ui.component.Selector.getConvertedValue(Selector.java:74)
    javax.faces.component.UIInput.validate(UIInput.java:638)
    javax.faces.component.UIInput.executeValidate(UIInput.java:849)
    javax.faces.component.UIInput.processValidators(UIInput.java:412)
    javax.faces.component.UIForm.processValidators(UIForm.java:170)
    javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:912)
    javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:912)
    javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:912)
    javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:912)
    javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:342)
    com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:78)
    com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:221)
    com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
    sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-2)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:585)
    org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
    java.security.AccessController.doPrivileged(AccessController.java:-2)
    javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
    org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
    org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:257)
    org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
    org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161)
    java.security.AccessController.doPrivileged(AccessController.java:-2)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
    com.sun.web.ui.util.UploadFilter.doFilter(UploadFilter.java:179)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:210)
    org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
    org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161)
    java.security.AccessController.doPrivileged(AccessController.java:-2)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:263)
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:225)
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:173)
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:132)
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:933)
    org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:185)
    com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:653)
    com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:534)
    com.sun.enterprise.web.connector.grizzly.ProcessorTask.doTask(ProcessorTask.java:403)
    com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:55)
    =====================================================

    Hi Abdelkrim,
    Try to place variable ArrayList mySelectedXXX
    to SessionBean and change your prerender code to something like that to reflect changes:
    //prerenderer method
    // you need this check in order to execute this code only first time page is rendered
    if (getSessionBean1().getMySelectedXXX() == null) {
        getSessionBean1().setMySelectedXXX(new ArrayList());
        while (resultSet.next()) {
            getSessionBean1().getMySelectedXXX().add(new Long(resultSet.getLong("id_XXX")));
        checkboxGroup1.setSelected(getSessionBean1().getMySelectedXXX());
    }Also you'll need to execute getSessionBean1().setMySelectedXXX(null); when you leave the page.
    Roman.

  • Problem with checkbox in JTable when using MyTableModel

    Hi all,
    I have been trawling these message boards for days looking for the answer to my question but have not had any success.
    I am extending AbstractTabel model to create MyTableModel which returns a vector containing the results of a MySql query. One column in this query returns a "0" or "1" which I then store as the boolean value into the vector so that it is rendered as a checkbox on the screen.
    I have also overridden the setValueAt method. THe problem is that when I attempt to check the box in the table, the checkbox isn't actually checking.
    Do I need to implement some sort of listener which picks up the user clicking the box and refresh the model?
    Here is my model code:
    public class MyTableModel extends AbstractTableModel {
        private Vector v = null;
        int listId;
        MyTableModel(int listId){
            this.listId = listId;
            v = new ListItemManagement().getFullList(listId);
       public Class getColumnClass(int c) {
            switch(c) {
                case 6:
                    return Boolean.class;
                default:
                    return Object.class;
        public String getColumnName(int colIndex){
            return ((String[])v.get(0))[colIndex];
        public int getColumnCount() {
            return ((String[])v.get(0)).length;
        public int getRowCount() {
            return (v.size() - 1);
        public Object getValueAt(int rowIndex, int colIndex) {
            return ((Object[])v.get(rowIndex + 1))[colIndex];
        public void setValueAt(Object aValue, int rowIndex, int colIndex) {
            System.out.println("Value: " + String.valueOf(aValue));
            Object row[] = (Object[]) v.elementAt(rowIndex);
            if(colIndex<6){
                row[colIndex] = (String)aValue;
            else{
                row[colIndex] = (Boolean)aValue;
            v.setElementAt(row, rowIndex);
            fireTableCellUpdated(rowIndex, colIndex);
        public boolean isCellEditable(int row, int col) {
            //Note that the data/cell address is constant,
            //no matter where the cell appears onscreen.
            return ! (col < 6);
        }Here is the getFullList function which returns the vector:
                rs = stmt.executeQuery();
                ResultSetMetaData colData = rs.getMetaData();
                int columnCount = colData.getColumnCount();
                String[] columnNames = new String[columnCount];
                for (int i = 0; i < columnCount; i++){
                    columnNames[i] = colData.getColumnName(i + 1);
                Vector v = new Vector();
                v.add(columnNames);
                while (rs.next()){
                    Object[] values = new Object[columnCount];
                    for (int i = 0; i < (columnCount-1); i++){
                        values[i] = rs.getString(i + 1);
                    int sel = rs.getInt("selected");
                    System.out.println(sel);;
                    if(sel==0){
                        values[columnCount-1]=new Boolean(false);
                    else if (sel==1)
                        values[columnCount-1]=new Boolean(true);
                    v.add(values);
                rs.close();
                stmt.close();
                return v;

    Thanks for the replies, much appreciated.
    I've looked at the Swing jtable tutorial and added a TableModelListener and have managed to achieve the desired results but for one thing.
    When I attempt to check the box on the first row of the jTable I get a runtime error:
    Exception in thread "AWT-EventQueue-0" java.lang.ArrayStoreException: java.lang.Boolean
    at project.MyTableModel.setValueAt(MyTableModel.java:65)
    I have been playing around with the setValueAt method and it is in my original post. Here is how it currently looks:
        public void setValueAt(Object aValue, int rowIndex, int colIndex) {
            System.out.println("Value: " + String.valueOf(aValue));
            Object row[] = (Object[]) v.elementAt(rowIndex);
            if(colIndex<6){
                row[colIndex] = (String)aValue;
            else{
                    if(getValueAt(rowIndex,colIndex).toString()=="true"){
                    row[6] = new Boolean(false);
                else{
                    row[6] = new Boolean(true);
            v.setElementAt(row, rowIndex);
            fireTableCellUpdated(rowIndex, colIndex);
        }

  • Problem with checkbox and drop down menu

    I am using DW8 with PHP/MySQL.
    I made a insertion form and a couple of the fields are
    checkboxes and another is a drop down menu. Everything works fine,
    however, when I create an update form and the recordset calls the
    data it doesn't retain its values on those items.
    For example, if I checked a box when inserting the record and
    then call the data up for the update form, the box is not checked,
    making the user believe it was never checked in the first place.
    The same thing goes for the drop down menu. If I have 3
    options in the menu and someone selects the third one, when the
    update form is used it defaults to the first option automatically
    instead of actually calling up the original value selected.

    The fact that two scripts do not work together does not mean
    there is a bug in the RH script. It is simply that they were not
    designed by their respective developers to work together. This
    happens with multiple scripts in any html file.
    Try creating a new project and then importing just this topic
    into it. Does it still have the problem?

  • How can I retrieve selected checkboxes by user into a JPA application?

    Hello, I'm developing an app in JPA, still learning this, I'm displaying some checkboxes which I save into a List, then I separate the selections and put them into an Array, which I convert into String and that's what I store into MySQL table, this is what I have on the index.xhtml file:
    <h:selectManyCheckbox value="#{employee.selectedItems}">
    <f:selectItems var="checkList" value="#{employee.checkboxList()}" itemValue="#{checkList.idTechnology}" itemLabel="#{checkList.name}"></f:selectItems>
    </h:selectManyCheckbox>
    The method checkboxList is in charge of generating the checkboxes and assign a value and name, and the method "selectedItems" is the List<String> that stores the selected checkboxes values, so what I save into the table is something like this: "1,4,6,7" but I don't know how to retrieve the selections and check the checxkboxes according the what the user have on the table:
    This is the method that I use to select all the records from the selected user, this fills all the textfields so I can edit the user, but not the checkboxes, and that's what I need to do:
    public void seleccionarEmpleado(int id_empleado){
    Query q = em.createNamedQuery("Employee.findByIdEmployee");
    q.setParameter("IdEmployee", IdEmployee);
    List<Empleado> listaEmple = q.getResultList();
    for(IdEmployee emple1 : listaEmple){
    emp.setIdEmployee(emple1 .getIdEmployeeo());
    emp.setName(emple1 .getName());
    emp.setLname(emple1 .getLname());
    emp.setTel(emple1 .getTel());
    emp.setAddress(emple1 .getDir());
    emp.setTech(emple1 .getTecha());
    Variable Tech is the one who gets the numbers like "2,3,4" etc, but how can I make the checkboxes to be checked according to these numbers? my english is not so good, thanks in advanced, have a nice day!

    Hello, I'm developing an app in JPA, still learning this, I'm displaying some checkboxes which I save into a List, then I separate the selections and put them into an Array, which I convert into String and that's what I store into MySQL table, this is what I have on the index.xhtml file:
    <h:selectManyCheckbox value="#{employee.selectedItems}">
    <f:selectItems var="checkList" value="#{employee.checkboxList()}" itemValue="#{checkList.idTechnology}" itemLabel="#{checkList.name}"></f:selectItems>
    </h:selectManyCheckbox>
    The method checkboxList is in charge of generating the checkboxes and assign a value and name, and the method "selectedItems" is the List<String> that stores the selected checkboxes values, so what I save into the table is something like this: "1,4,6,7" but I don't know how to retrieve the selections and check the checxkboxes according the what the user have on the table:
    This is the method that I use to select all the records from the selected user, this fills all the textfields so I can edit the user, but not the checkboxes, and that's what I need to do:
    public void seleccionarEmpleado(int id_empleado){
    Query q = em.createNamedQuery("Employee.findByIdEmployee");
    q.setParameter("IdEmployee", IdEmployee);
    List<Empleado> listaEmple = q.getResultList();
    for(IdEmployee emple1 : listaEmple){
    emp.setIdEmployee(emple1 .getIdEmployeeo());
    emp.setName(emple1 .getName());
    emp.setLname(emple1 .getLname());
    emp.setTel(emple1 .getTel());
    emp.setAddress(emple1 .getDir());
    emp.setTech(emple1 .getTecha());
    Variable Tech is the one who gets the numbers like "2,3,4" etc, but how can I make the checkboxes to be checked according to these numbers? my english is not so good, thanks in advanced, have a nice day!

  • How to show/hide div based on mysql value

    I have a dataset that has a column 'locked' that is a boolean that I want to use to remove a button on a form.  The idea being that it will be set to 1 after a period of time thus removing the buttun that links to an update form and preventing the data from being changed.  Currently, I have the field linked to a check box at the top of the table.  How do I use this to hide the button (or any other html element for that matter) when set to 1 and show the element when set to 0?  I understand I need to creat a php variable from the mysql boolean and then use a if/else loop to hide/display the html but I don't know how to impliment this?  Thanks for any help offered.
    Here's the code:
    <?php require_once('Connections/testmypms.php'); ?>
    <?php
    $currentPage = $_SERVER["PHP_SELF"];
    $maxRows_spec_rx = 10;
    $pageNum_spec_rx = 0;
    if (isset($_GET['pageNum_spec_rx'])) {
      $pageNum_spec_rx = $_GET['pageNum_spec_rx'];
    $startRow_spec_rx = $pageNum_spec_rx * $maxRows_spec_rx;
    $colname_spec_rx = "1";
    if (isset($_GET['pxID'])) {
      $colname_spec_rx = (get_magic_quotes_gpc()) ? $_GET['pxID'] : addslashes($_GET['pxID']);
    mysql_select_db($database_testmypms, $testmypms);
    $query_spec_rx = sprintf("SELECT spec_rx.spec_rx_id, spec_rx.FK_px_id, DATE_FORMAT(spec_rx.spec_rx_date, '%%d-%%m-%%Y') as formatted_rx_date, spec_rx.FK_user_id, spec_rx.spec_rx_rsph, spec_rx.spec_rx_rcyl, spec_rx.spec_rx_raxis, spec_rx.spec_rx_rhprism, spec_rx.spec_rx_rhprismbase, spec_rx.spec_rx_rvprism, spec_rx.spec_rx_rvprismbase, spec_rx.spec_rx_rnadd, spec_rx.spec_rx_rnhprism, spec_rx.spec_rx_rnhprismbase, spec_rx.spec_rx_rnvprism, spec_rx.spec_rx_rnvprismbase, spec_rx.spec_rx_rintadd, spec_rx.spec_rx_rinthprism, spec_rx.spec_rx_rinthprismbase, spec_rx.spec_rx_rintvprism, spec_rx.spec_rx_rintvprismbase, spec_rx.spec_rx_lsph, spec_rx.spec_rx_lcyl, spec_rx.spec_rx_laxis, spec_rx.spec_rx_lhprism, spec_rx.spec_rx_lhprismbase, spec_rx.spec_rx_lvprism, spec_rx.spec_rx_lvprismbase, spec_rx.spec_rx_lintadd, spec_rx.spec_rx_linthprism, spec_rx.spec_rx_linthprismbase, spec_rx.spec_rx_lintvprism, spec_rx.spec_rx_lintvprismbase, spec_rx.spec_rx_lnadd, spec_rx.spec_rx_lnhprism, spec_rx.spec_rx_lnhprismbase, spec_rx.spec_rx_lnvprism, spec_rx.spec_rx_lnvprismbase, spec_rx.locked, users.user_id, users.user_firstname, users.user_surname FROM spec_rx, users WHERE %s = spec_rx.FK_px_id AND spec_rx.FK_user_id = users.user_id ORDER BY spec_rx.spec_rx_date DESC, spec_rx.spec_rx_id DESC", $colname_spec_rx);
    $query_limit_spec_rx = sprintf("%s LIMIT %d, %d", $query_spec_rx, $startRow_spec_rx, $maxRows_spec_rx);
    $spec_rx = mysql_query($query_limit_spec_rx, $testmypms) or die(mysql_error());
    $row_spec_rx = mysql_fetch_assoc($spec_rx);
    if (isset($_GET['totalRows_spec_rx'])) {
      $totalRows_spec_rx = $_GET['totalRows_spec_rx'];
    } else {
      $all_spec_rx = mysql_query($query_spec_rx);
      $totalRows_spec_rx = mysql_num_rows($all_spec_rx);
    $totalPages_spec_rx = ceil($totalRows_spec_rx/$maxRows_spec_rx)-1;
    $colname_demographics = "1";
    if (isset($_GET['pxID'])) {
      $colname_demographics = (get_magic_quotes_gpc()) ? $_GET['pxID'] : addslashes($_GET['pxID']);
    mysql_select_db($database_testmypms, $testmypms);
    $query_demographics = sprintf("SELECT demographics.px_id, demographics.FK_title_id, demographics.firstname, demographics.surname, DATE_FORMAT(demographics.dob, '%%d-%%m-%%Y') as formatted_dob, title.title_id, title.title FROM demographics, title WHERE %s = demographics.px_id AND demographics.FK_title_id = title.title_id", $colname_demographics);
    $demographics = mysql_query($query_demographics, $testmypms) or die(mysql_error());
    $row_demographics = mysql_fetch_assoc($demographics);
    $totalRows_demographics = mysql_num_rows($demographics);
    $queryString_spec_rx = "";
    if (!empty($_SERVER['QUERY_STRING'])) {
      $params = explode("&", $_SERVER['QUERY_STRING']);
      $newParams = array();
      foreach ($params as $param) {
        if (stristr($param, "pageNum_spec_rx") == false &&
            stristr($param, "totalRows_spec_rx") == false) {
          array_push($newParams, $param);
      if (count($newParams) != 0) {
        $queryString_spec_rx = "&" . htmlentities(implode("&", $newParams));
    $queryString_spec_rx = sprintf("&totalRows_spec_rx=%d%s", $totalRows_spec_rx, $queryString_spec_rx);
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Spec Rx3</title>
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_goToURL() { //v3.0
      var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
      for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
    //-->
    </script>
    </head>
    <body>
    <p>Spec Rx</p>
    <p><?php echo $row_demographics['px_id']; ?></p>
    <p><?php echo $row_demographics['title']; ?> <?php echo $row_demographics['firstname']; ?> <?php echo $row_demographics['surname']; ?> <?php echo $row_demographics['formatted_dob']; ?> </p>
    <p>
      <input name="Add_spec_rx" type="button" id="Add_spec_rx" onClick="MM_goToURL('parent','add_spec_rx.php');return document.MM_returnValue" value="New Rx">
    </p>
    <p> <a href="<?php printf("%s?pageNum_spec_rx=%d%s", $currentPage, max(0, $pageNum_spec_rx - 1), $queryString_spec_rx); ?>">Previous</a> <a href="<?php printf("%s?pageNum_spec_rx=%d%s", $currentPage, min($totalPages_spec_rx, $pageNum_spec_rx + 1), $queryString_spec_rx); ?>">Next</a></p>
    <?php do { ?>
    <table border="1" cellspacing="1" cellpadding="5">
      <tr>
        <td> </td>
        <td><?php echo $row_spec_rx['formatted_rx_date']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_id']; ?></td>
        <td>locked:
        <input <?php if (!(strcmp($row_spec_rx['locked'],1))) {echo "checked";} ?> name="locked" type="checkbox" id="locked" value="1"></td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
        <td>Sph</td>
        <td>Cyl</td>
        <td>Axis</td>
        <td>HPrism</td>
        <td>HPrismBase</td>
        <td>VPrism</td>
        <td>VPrismBase</td>
        <td>NrAdd</td>
        <td>NrHPrism </td>
        <td>NrHPrismBase</td>
        <td>NrVPrism</td>
        <td>NrVPrismBase</td>
        <td>IntAdd</td>
        <td>IntHPrism</td>
        <td>IntHPrismBase</td>
        <td>IntVPrism</td>
        <td>IntVPrismBase</td>
      </tr>
      <tr>
        <td>R</td>
        <td><?php echo ($row_spec_rx['spec_rx_rsph']<>null) ? sprintf ("%+4.2f",$row_spec_rx['spec_rx_rsph']) : null; ?></td>
        <td><?php echo ($row_spec_rx['spec_rx_rcyl']<>null) ? sprintf ("%+4.2f",$row_spec_rx['spec_rx_rcyl']) : null; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_raxis']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rhprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rhprismbase']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rvprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rvprismbase']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rnadd']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rnhprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rnhprismbase']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rnvprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rnvprismbase']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rintadd']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rinthprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rinthprismbase']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rintvprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rintvprismbase']; ?></td>
      </tr>
      <tr>
        <td>L</td>
        <td><?php echo ($row_spec_rx['spec_rx_lsph']<>null) ? sprintf ("%+4.2f",$row_spec_rx['spec_rx_lsph']) : null; ?></td>
        <td><?php echo ($row_spec_rx['spec_rx_lcyl']<>null) ? sprintf ("%+4.2f",$row_spec_rx['spec_rx_lcyl']) : null; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_laxis']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lhprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lhprismbase']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lvprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lvprismbase']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lnadd']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lnhprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lnhprismbase']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lnvprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lnvprismbase']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lintadd']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_linthprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_linthprismbase']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lintvprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lintvprismbase']; ?></td>
      </tr>
      <tr>
        <td> </td>
        <td>User ID <?php echo $row_spec_rx['user_id']; ?></td>
        <td><?php echo $row_spec_rx['user_firstname']; ?></td>
        <td><?php echo $row_spec_rx['user_surname']; ?></td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
    </table>
    <p> </p>
    <?php } while ($row_spec_rx = mysql_fetch_assoc($spec_rx)); ?>
    <p> </p>
    <p> </p>
    <p> </p>
    </body>
    </html>
    <?php
    mysql_free_result($spec_rx);
    mysql_free_result($demographics);
    ?>

    Thanks for your help, nearly worked but only returned results where the if statement was met ie where locked =0, so I used an additional statement to display something else when when locked=1
    <?php
    if($row_spec_rx['locked'] == 1) {
    echo "button html goes here";
    ?>
    <?php
    if($row_spec_rx['locked'] == 0) {
    echo "something else";
    ?>
    I am sure there must be a more elegant way of doing this!

  • What is the Plugin that puts checkboxes next to links so that all cheked links are opened?

    I can't remember what was the plugin or maybe it was a plugin with Maxthon but the feature is somewhat like this:
    In a webpage there are several links of interest, and this plugin toggled checkboxes next to the links for ticking. Then only those selected links would be opened. This is similar to Snap Links or Multi-Links, but a different way of handling multiple links which may be spread across the page.
    With the checkboxes, one only needs to keep putting ticks next to the interesting links as one reads a page and later open all the selected/checked links.
    Update1: Yes, it was a Maxthon plugin called OpenCheckedLinks. This is a much needed feature for Firefox.
    Update2: Ok, found Firefox Plugin called Linky, which does solve this problem partially by listing the urls to select, but it does not carry the anchor text. Maybe the developer will include that feature.

    >$result=mysql_query("SHOW TABLES FROM sand2 LIKE '%$find%'")
    >
    >Should it be SELECT * FROM TABLENAME ?
    The OP is searhing the system tables for a user table in a database. With most dbms's you would select from the system table for the object. MySql has the Show command.
    http://dev.mysql.com/doc/refman/5.0/en/show-tables.html

  • Store color (uint) in MySQL table using PHP

    The PHP service wizard doesn't support uint.
    PHP doesn't have a uint type but MySQL does.
    How do I send a color from Flex to MySQL?

    Now just to be certain, I don't want to store every value from the checkbox array in a separate row,
    I want them to be all on one row of one column and can be broken down into their individual components upon request.
    The data must be stored in a manner that makes it possible to count and analyze.These two statements to me appear to be slightly at odds.
    To me it would be simpler if each checkbox had a seperate column - or at least each group of checkboxes as long as you are going to analyze them together.
    It depends upon what sort of questions will be asked of it.
    eg "How many people ticked checkbox #4"
    If you need to retrieve every single row, and do a calculation on the value to find the answer out, then it is not going to be efficient.

  • Spry validation stops me writing a MySQL record

    Good morning,
    This is very strange and has been driving me nuts for a couple of days now. Using DW CS6/ Win 7/ IE 11/ FF/ Chrome.
    I had an application form that worked correctly, validated input and wrote a new record to a MySQL db. I had to develop a very similar web page so I took the existing page and updated it.
    I have found, after a lot of trial and error, that I can write a new record containing valid data but spry doesn't work - no validation and no hints appear in the text boxes. Or, I can get spry validation to work but the web page hangs when I try and write a new record.
    Amongst other changes, the old page had a checkbox which I deleted from the new page and there are no other checkboxes on the page. When i remove the js  "var sprycheckbox2 = new Spry.Widget.ValidationCheckbox("sprycheckbox2");" Spry validation works, hints appear etc but the page hangs when I click the "Next Step" button which should write to the db. if I leave the js for the widget in the page I don't get any spry validation or hints but the record is written to the db. In both cases I had commented out the link to "SpryValidationCheckbox.js".
    Here's a link to the version which has the widget http://www.hollisterairshow.com/rally/vendorApp2.php?blapp=inline&tspapp=inline&tfpapp=inl ine , this has no hints in the text boxes and spry validation doesn't happen at all, but it does write a record to the db. here's a link to the version where I commented out the js for the checkbox widget - it's the second one in the list of widgets at the end of the page. I made no other changes http://www.hollisterairshow.com/rally/vendorApp3.php?blapp=inline&tspapp=inline&tfpapp=inl ine
    It looks like the widgets were added at the end of the google analytics code but I don't know if this is relevant.
    I'm also getting widgets listed as missing when I open the page in DW, the checkbox I referred to is the first one listed below, could this be relevant? Do I just delete the js for each of the widgets listed?  Sorry if this is a basic question, I'm getting very confused at this point.
    i'd really appreciate some direction in trying to fix this.
    Thanks,
    Tony

    I took a look at jqueryvalidate and it looks straightforward, my only reservation is that it doesn't appear to support hints in the form fields e.g. in a zip code field "5 digit Zip" etc. I googled around and found yet another library that claims to do this. So now I'm looking at adding two libraries I'm not familiar with and rewriting my form.
    I was really hoping a fresh pair of eyes could spot something I'm missing - the old version of this form worked, and still works. When I added/ deleted a few fields to the new version my problems started.
    Thanks again..

  • Checkbox DataGrid Item Render Issue

    I have a DataGrid component that has a column with a checkbox
    item render. The code at the end of this post is identical to the
    code at the bottom of the tutorial on this page:
    Tutorial
    The creation complete method calls a PHP function using the
    AMFPHP framework. The PHP function returns an array of MySQL rows.
    When I created the application initially, I was using the HTTP
    Service component that would return the data as an XML list and
    then Flex would bring it in as an Array Collection. The only thing
    I changed was how the records were getting returned to Flex, which
    is using AMFPHP. Now the item render does not function properly. If
    the first record returned had a value of "true" then all the
    subsequent rows would have their check boxes checked. If it were
    "false" then the subsequent rows would have their check boxes
    unchecked. Why is it doing this? It worked the way it was suppose
    to before.
    Also I have a label component nested in the itemRenderer to
    see if it matches the data in the MySQL database; which it does
    match. Here is a screenshot of what exactly I am seeing:
    Screenshot

    Maybe the values being returned must be cast to Boolean
    now?

  • Php, mysql, apache, windows xp

    I use the most recent versions of php, apache, mysql and
    windows xp. And I use Dreamweaver 2004MX.
    I create a very simple index.php and when I preview on a
    browser, the address becomes like this.
    http://localhost/artgallery/TMP2zjuplef9z.php
    instead of index.php at the end in the browser address.
    Each time when I preview it, it create random address at the
    end instead of index.php.
    Why does it create like this? Is there anything I can fix
    this?

    However, doing this will prevent your root relative links (if
    any), and
    server-side includes (I think) from rendering properly in
    preview.
    My suggestion would be to ignore it for you local previews.
    It's how DW
    works.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "Nancy - Adobe Comm. Expert" <[email protected]> wrote
    in message
    news:f7mq70$esk$[email protected]..
    > Edit/Preferences/Preview in Browser. Uncheck the "create
    temporary files"
    > checkbox and restart Dreamweaver.
    >
    >
    > --
    > Nancy Gill
    > Adobe Community Expert
    > Author: Dreamweaver 8 e-book for the DMX Zone
    > Co-Author: Dreamweaver MX: Instant Troubleshooter
    (August, 2003)
    > Technical Editor: Dreamweaver CS3: The Missing Manual,
    > DMX 2004: The Complete Reference, DMX 2004: A Beginner's
    Guide
    > Mastering Macromedia Contribute
    > Technical Reviewer: Dynamic Dreamweaver MX/DMX: Advanced
    PHP Web
    > Development
    >
    > "shinceciokada" <[email protected]>
    wrote in message
    > news:f7mm6c$ai7$[email protected]..
    >>I use the most recent versions of php, apache, mysql
    and windows xp. And I
    >>use
    >> Dreamweaver 2004MX.
    >> I create a very simple index.php and when I preview
    on a browser, the
    >> address
    >> becomes like this.
    >>
    http://localhost/artgallery/TMP2zjuplef9z.php
    instead of index.php at the
    >> end
    >> in the browser address.
    >> Each time when I preview it, it create random
    address at the end instead
    >> of
    >> index.php.
    >> Why does it create like this? Is there anything I
    can fix this?
    >>
    >>
    >
    >

  • MySQL+JTable, AbstractTableModel - solution v.0.1 beta

    Hi everybody, My name is Sergey, I am a student from Russian Federation, Moscow.
    I spent days and nights trying to find how to connect JTable, DB tables.
    To tell you the truth, I visited many russian and english-lang forums. But I didn't get somewhere goog answer. that is terrible.
    Seems like nobody nows how to do simple things.
    So, I've started to do on my own. And I suggest you the first version.
    Ofcourse it is rather raw, but it works.
    Sometimes I was really angry when people suggested others untested and foolish code. With mistakes.
    what we need:
    JDBC adapter - mysql.com (you canget it)
    MySQL server (must be started)
    DB
    Tables in DB
    NetBeans 5.5 - netbeans.org
    NB MySQL server on localhost, thisway you will not need to dig mysql config files
    Create new project application
    Add mysql driver jar file to project library (it is in project window)
    create two classes and enjoy
    import java.sql.*;
    import java.util.Collections;
    import java.util.List;
    import java.util.Vector;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.table.AbstractTableModel;
    import java.util.Collections;
    * @author SShpk
    //we are going to override methods of AbstracTableModel Class
    /**This class forms view of DB table which will be loaded into JTable swing component*/
    public class JTableAdapter extends AbstractTableModel{
            //my table name
            private String tableName ="Sheet";
         //frame for error exception output
            private JFrame jframeError = new JFrame("Connection error");
            //variables for transactions
            private Connection connection;
            private Statement  statement;
            private ResultSet  resultSet;
            private ResultSetMetaData metaData;
            //names of colums --- will get them from DB table
            public  String[]   columnNames;
            //this Vector will  keep rows of table
            private Vector     rows = new Vector();
            private int i;
            private String t="";
        /** Creates a new instance of JTableAdapter */
        public JTableAdapter(String url, String driverName, String user, String password) {
            jframeError.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//frame for showing errors
            //this String var I use to avoid problem with Date/Datestamps e.t.c. like �0000-00-00�
         //because java converts them to NULL. This is terrible fact. Do not lose this comment!
            String overrideBADDATE="zeroDateTimeBehavior=convertToNull&";
         //let�s put together all params
            //common view is: :jdbc:mysql://yourhost.com:port_num/NameofYourDB?<property&>
            t=url+overrideBADDATE+"user="+user+"&password="+password;
            try{     //trying to load driver
                Class.forName(driverName);
                connection=DriverManager.getConnection(t);
                statement = connection.createStatement();
                                    //this commented code will be useful for you in debug proccess.
                                    //it will give you list of all loaded drivers to driver managers
                                    //so you will be able to see is your jdbc driver loaded or not.
                                     try{
                                          List drivers = Collections.list(DriverManager.getDrivers());
                                          for(int i=0;i<drivers.size();i++){
                                              Driver driver = (Driver)drivers.get(i);
                                              String driverName1 = driver.getClass().getName();
                                              System.out.println("Driver "+i+":::"+driverName1);
                                     }catch(Exception e){
                                          System.out.println(e);
                                     }//catch in try
            }//try
            //let's catch exceptions.
            //see messages to get the meaning of exception
            catch(ClassNotFoundException ex){
                         JOptionPane.showMessageDialog(jframeError,
                                                        "Error occurred during driver load"+driverName,
                                                        "Driver load error:"+ex.getMessage(),
                                                        JOptionPane.ERROR_MESSAGE);
                                                        jframeError.setVisible(true);
            }//catch1
            catch(SQLException ex){
                         JOptionPane.showMessageDialog(jframeError,
                                                        "Error connecting DB"+url,
                                                        "DB Connection error:"+ex.getMessage(),
                                                        JOptionPane.ERROR_MESSAGE);
                                                        jframeError.setVisible(true);
            }//catch2
        //executing SELECT query to fill our table
         executeQuery("SELECT * FROM " + this.tableName);  
        }//constructor
        /**method sends SELECT query and parses result of this query*/
        public void executeQuery(String query){
            //testing for alive connection
            if(connection== null || statement == null){
                            JOptionPane.showMessageDialog(jframeError,
                                                        "Error occurred during query post",
                                                        "DB connection error",
                                                        JOptionPane.ERROR_MESSAGE);
                                                        jframeError.setVisible(true);
         //let�s parse result of query
            try{
                resultSet = statement.executeQuery(query);
                //get num of columns in table   /***/getColumnCount()
                //get names of columns          /***/getColumnLabel(i+1)
                metaData = resultSet.getMetaData();
                int numberOfColumns = metaData.getColumnCount();
               //getting names of DB table columns
                columnNames = new String[numberOfColumns];
                for(i=0;i<numberOfColumns;i++){
                        columnNames= metaData.getColumnLabel(i+1);
    }//for
    Object testnulledobj;
    rows = new Vector();
    //from the beginning of resultSet up to the END
    while (resultSet.next()){
    //each row of DB table is Vector
    Vector newRow = new Vector();
    for (i=1; i<= getColumnCount();i++){
    testnulledobj=resultSet.getObject(i);
         //this IF statement I will develop
    //to output NULL-object Date (like Date field = 0000-00-00)
    if(resultSet.wasNull()){
    testnulledobj=new String("");
    newRow.addElement(testnulledobj);
    }//for
              //row from DB is completed. Every row will be in Vector of Rows.
              //I hope you got my idea.
              //We collect row cells of DB table row in Vector
              //Then we put this Vector into another Vector, which consists of DB rows
    rows.addElement(newRow);
    }//while
    //table is changed
    fireTableChanged(null);
    }//try
    catch(SQLException ex){
    JOptionPane.showMessageDialog(jframeError,
    "Error occurred during query result parsing",
    "Data accept error",
    JOptionPane.ERROR_MESSAGE);
    jframeError.setVisible(true);
    }//executeQuery
    /**cell of table editable or not?*/
    public boolean isCellEditable(int row,int column){
    /*Testing field(aka column) property. We get it from DB.
    try{
    return metaData.isWritable(column+1);
    }//try
    catch(SQLException e){
    return false;
    }//catch
    /****LOCKING ID FIELD***/
    if(column>0) return true;
    else return false;
    }//isCellEditable
    //these three methods very simple. I think they do not need any explanations
    /**set column name in JTable*/
    public String getColumnName(int column){
    return this.columnNames[column];
    /**get quantity of rows in table*/
    public int getRowCount(){
    return this.rows.size();
    /**get quantity of columns in table*/
    public int getColumnCount(){
    return this.columnNames.length;
    /**get value from JTable cell*/
    public Object getValueAt(int aRow, int aColumn){
    Vector row = (Vector)rows.elementAt(aRow);
    return row.elementAt(aColumn);
    //if user edited cell (double-click on it and then went away)
    //we need to update DB table and JTable also.
    //this is not pretty good variant, because we will flood DB with plenty of small queries.
    //the best way is to save value of "double-clicked" cell. Then we have to compare its value before
    //focus and after. If values differ, then we update DB table, else � no update
    //unfortunately I do not know how to control focus method of JTable cell
    /**update DB table cell value*/
    public void setValueAt(Object value, int row, int column){
    //Before updating DB table cell we need to update JTable cell
    Object val;
    val = tbRepresentation(column, value);
    Vector dataRow = (Vector)rows.elementAt(row);
    dataRow.setElementAt(val,column);
    //Now it's time to update DB table
    try{
    //get name of column in DB table (our JTable has the same column names)
    //it's possible to give them normal names instead of user_id,user_name e.t.c.
    //I am sure, user of your app will prefer to see normal names of columns, not like listed before
    String columnName = getColumnName(column);
    //This is very bad example of update query.
    //You have to determine automatically key field. but still I didn't find how to do that
    //But it's possible to do through metadata. I am sure.
    //Just need some more time
    //When I am designing DB I prefer to name key field in each table as "ID"
    String query = "UPDATE "
    tableName
    " SET "+columnName+" = "+"'"+dbRepresentation(column,getValueAt(row, column))+"'"+
    " WHERE ID = "+dbRepresentation(0,getValueAt(row, 0));
    //extremely important string for debug
    System.out.println("UPDATE QUERY:::"+query);
    //executing update query
    PreparedStatement pstmt = connection.prepareStatement(query);
    pstmt.executeUpdate();
    }//try
    catch(Exception ex){
    JOptionPane.showMessageDialog(jframeError,
    "������ ��� ���������� ������ � ������� ��",
    "������ �������� ��� ���������� ������ � ��",
    JOptionPane.ERROR_MESSAGE);
    jframeError.setVisible(true);
    }//catch
    }//setValueAt
    //Next two methods are very neccessary. And they need accurate testing
    //they convert DB datatypes into java datatypes and backwards
    /**convert SQL (MySQL in this case) datatypes into datatypes which java accepts*/
    public Object tbRepresentation(int column, Object value) throws NumberFormatException{
    Object val;
    int type;
    if(value == null){
    return "null";
    }//if null
    try{
    type = metaData.getColumnType(column+1);
    }//try
    catch (SQLException e){
    JOptionPane.showMessageDialog(jframeError,
    "Error occured during Table update",
    "Error occured during DB table field type get",
    JOptionPane.ERROR_MESSAGE);
    jframeError.setVisible(true);
    return value.toString();
    }//catch
    switch(type){
    case Types.BIGINT:
    return val = new Long(value.toString());
    case Types.TINYINT:
    case Types.SMALLINT:
    case Types.INTEGER:
    return val = new Integer(value.toString());
    case Types.REAL:
    case Types.FLOAT:
    case Types.DOUBLE:
    case Types.DECIMAL:
    return val = new Double(value.toString());
    case Types.CHAR:
    case Types.BLOB:
    case Types.VARCHAR:
    case Types.LONGNVARCHAR:
    return val = new String(value.toString());
    case Types.DATE:
    return val = new String(value.toString());
    default: return val = new String(value.toString());
    }//switch
    }//tbRepresentation
    /**conver Java datatypes into SQL (MySQL) datatypes*/
    public Object dbRepresentation(int column, Object value){
    Object val;
    int type;
    if(value == null){
    return "null";
    }//if null
    //my preparations for accurate work with "nulled" dates/time/e.t.c
    //this IF statement doesn't play any important role
    String testbaddate="0000-00-00";
    if(value.toString().equals(testbaddate)){
    return value.toString();
    try{
    type = metaData.getColumnType(column+1);
    }//try
    catch (SQLException e){
    return value.toString();
    }//catch
    switch(type){
    case Types.BIGINT:
    return val = new Long(value.toString());
    case Types.TINYINT:
    case Types.SMALLINT:
    case Types.INTEGER:
    return val = new Integer(value.toString());
    case Types.DECIMAL:
    case Types.FLOAT:
    case Types.DOUBLE:
    return val = new Double(value.toString());
    case Types.VARCHAR:
    case Types.CHAR:
    return val = new String(value.toString());
    case Types.DATE:
    return val = new String(value.toString());
    default: return val = new String(value.toString());
    }//switch
    }//dbRepresentation
    //my preparations to read from SELECT query result
    //"nulled" dates/time/e.t.c.
    private Object testObject(Object obj){
    Object val= new String("");
    if(obj==null) return new String(val.toString());
    else return obj;
    }//class
    And other class. I will not comment it.
    It is very easy. Ask me if you want something
    import java.awt.Dimension;
    import java.awt.GridLayout;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    public class TableCreate extends JPanel{
        /** Creates a new instance of TableCreate */
        public TableCreate() {
            super(new GridLayout(1,0));
            JTable table = new JTable(new JTableAdapter("jdbc:mysql://localhost/Document?","com.mysql.jdbc.Driver","root",""));
            table.setPreferredScrollableViewportSize(new Dimension(500,210));
            JScrollPane scrollpane = new JScrollPane(table);
            add(scrollpane);
        public JPanel getJpanelTable(){
            return this;
        public static void main(String[] args){
            JFrame jframe = new JFrame("Test");
                TableCreate tcreate = new TableCreate();
                    jframe.add(tcreate.getJpanelTable());
                    jframe.pack();
                    jframe.setVisible(true);
    }//main

    So what we have:
    -DB table insert into JTable
    -Can edit values+update them in DB
    -override some common "critical points"
    What we need:
    -control row,col size in JTable
    -control column names in JTable
    -add combobox on fields which keep ID of other instance (I will give test example later)
    -add checkbox to boolean fields and to boolean fields which declared as int-family type, but use only "0" and "1" numbers
    -Add sort to JTable (to its header)
    -Add conrol buttons
    --new row
    --delete row
    --next record
    --previous record
    -Add user friendly GUI (highlight selected row e.t.c.)
    So as you can see, a lot of things to do
    I will be happy to answer all you questions
    But if you want to make me really happy- comment my post and suggest me how to refact code and approach this JTableAdapter class to reusable component (I want it to be useful in common cases when Java-specialist work with DB especially with MySQL)

Maybe you are looking for

  • App Freezes in when opening a link in a pdf displayed in StageWebView, is there a solution to this?

    When viewing a PDF in a StageWebView on ios6 iPad3, opening a link is setup to open externally. This works on tapping links, however holding down on the link, and pressing 'Open' freezes the app (forces you to close the app completely and reopen). Is

  • CRM_COND_COM_BADI not triggered

    Hello,         I have implemented the Pricing BADI in CRM 7.0. I have written some code in IF_EX_CRM_COND_COM_BADI~ITEM_COMMUNICATION_STRUCTURE to populate a custom field. I have saved and activated all the interfaces. Now when I am in CRMD_ORDER, I

  • Reconciliation of data

    Hi Experts, Can anyone explain what is reconciliation of data and why do we do that  and what are the steps for that process. Pease reply.Points will be assigned. Thsnks, Sai.

  • Native method from dll

    Hello, I am trying to call a dll:method. But I got the unsatisfiedLinkError. Can anyoen tell me way? Here is the code and teh dll: [java code] class Main public static void main(String[] args) HelloWorld hw = new HelloWorld(); hw.Java_Show_EM_Result(

  • Authorisation Object for reporting

    I created a Authorisation Object on an Infoobject .The list that comes up for selecting the Infocubes which should be effected by this doesnot show the Cube in which the Infoobject is used. The list shows various ODS and Cubes and I dont know how the