Urgent:display result from JTable

need help making the following in my code work:
1.how do i display the whole table in my code using a dialog box or JOptionPane.
2. i want to display a message beneath the table show the total price of items selected from the JComboBox .
3.is there any way i could add a method or sommething that display detail of each item seleted from the list in a seperate column of the JTable in my code.say for instance,if i selects beans,1 cup, 100 and it display protein in a seperate column in the JTable.
Thanks in advance.
my code:
'\n'
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.table.*;
import java.util.*;
public class BreakFast extends JFrame implements ActionListener{
     private JList ingredient;
     private JTable table;
     private DefaultTableModel model;
     private JButton move;
     private String[] food;
     private JComboBox box,box1;
     private String[] units;
     private double[] price={100,150,200,250,300,350,400};
     private JButton finish;
     public BreakFast(){
          Container c=getContentPane();
          c.setLayout(new FlowLayout());
          food = new String[] {"Corn Flakes","Beans","Shredded Bread","Mushroom",
          "eggs","Milks","Butter","Sugar","water","Oil"};
          ingredient = new JList(food);
          ingredient.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
          ingredient.setVisibleRowCount(4);
          JPanel p = new JPanel();
          p.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
          move = new JButton(">>>");
          move.addActionListener(this);
          //meal = new JTextArea(5,20);
          //meal.setEditable(false);
          p.add(new JScrollPane(ingredient),"Wast");
          JPanel p2 = new JPanel();
          p2.setBorder(new BevelBorder(BevelBorder.RAISED));
          units = new String[]{"2 cups","3 cups","4 cups","5 cups","1 mudu","2 mudu",
                    "3 mudu","4 mudu","5 mudu","6 mudu","7 mudu","8 mudu","9 mudu",
                    "1 bag"};
          box = new JComboBox(units);
          box.addActionListener(this);
          box1 = new JComboBox();
          //box1.setEditable(true);
          box1.addActionListener(this);
          for(int i=0;i<price.length;i++){
               box1.addItem(price);
          model = new DefaultTableModel();
          //model.addColumn("No.");
          model.addColumn("Food Items");
          model.addColumn("Units");
          model.addColumn("Price");
          table = new JTable(model);
          JScrollPane pane = new JScrollPane(table);
          pane.setPreferredSize(new Dimension(350,100));
          finish = new JButton("Finish");
          finish.addActionListener(this);
          p.add(box,"West");
          p.add(box1,"Center");
          p.add(move,"East");
          p2.add(pane,"North");
          p2.add(finish,"South");
          c.add(p);
          c.add(p2);
          setSize(450,300);
          setVisible(true);
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     public void actionPerformed(ActionEvent e){
     Object[] value = ingredient.getSelectedValues();
     if(e.getSource() == move){
     for(int i=0;i < value.length;i++){
     String word = (String)value[i];
     Vector<Object> data = new Vector<Object>();
     data.addElement( word );
data.addElement( box.getSelectedItem() );
data.addElement( box1.getSelectedItem());
     model.addRow( data );
     if(e.getSource() == finish){
          JOptionPane.showMessageDialog(BreakFast.this,table,"Selection Summary",JOptionPane.PLAIN_MESSAGE);
          System.exit(0);
     public static void main(String[] arg){
          new BreakFast();

Multi-Post:
http://forum.java.sun.com/thread.jspa?threadID=5122371&tstart=0
Ignored.

Similar Messages

  • HELP! Displaying results from a database in table format

    I'm developing a web application that will use a considerable number of database queries that need to be displayed back to the web-browser in HTML table format.
    I have been told that that result sets can allow tables to be built automatically without having to write the same loop and display code over and over.
    So far I have a HtmlResultSet class as follows:
    import java.sql.*;
    public class HtmlResultSet {
    private ResultSet rs;
    public HtmlResultSet(ResultSet rs) {
    this.rs = rs;
    public String toString() {  // can be called at most once
    StringBuffer out = new StringBuffer();
    // Start a table to display the result set
    out.append("<TABLE>\n");
    try {
    ResultSetMetaData rsmd = rs.getMetaData();
    int numcols = rsmd.getColumnCount();
    // Title the table with the result set's column labels
    out.append("<TR>");
    for (int i = 1; i <= numcols; i++) {
    out.append("<TH>" + rsmd.getColumnLabel(i));
    out.append("</TR>\n");
    while(rs.next()) {
    out.append("<TR>"); // start a new row
    for (int i = 1; i <= numcols; i++) {
    out.append("<TD>"); // start a new data element
    Object obj = rs.getObject(i);
    if (obj != null)
    out.append(obj.toString());
    else
    out.append(" ");
    out.append("</TR>\n");
    // End the table
    out.append("</TABLE>\n");
    catch (SQLException e) {
    out.append("</TABLE><H1>ERROR:</H1> " + e.getMessage() + "\n");
    return out.toString();
    I also have created a class that includes an instance of the class above to display the results, as follows:
    import java.io.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class customerLookup2 {
    public void doGet(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException {
    Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();
    try{
    Class.forName("org.gjt.mm.mysql.Driver");
    con = DriverManager.getConnection("jdbc:mysql://localhost:3306/sandywalker");
    out.println("<html>");
    out.println("<head><title> Users</title></head>");
    out.println("<body> Customers");
    HtmlResultSet result = new HtmlResultSet ("SELECT * FROM USERS");
    out.println("</body></html>");
    catch(ClassNotFoundException e ) {
    out.println("Couldn't load database driver: " + e.getMessage());
    catch(SQLException e) {
    out.println("SQLExeption caught: " +e.getMessage());
    finally {
    try {
    if (con !=null) con.close();
    catch (SQLException ignored) { }
    I keep getting a compile error "customerLookup2.java": Error #: 300 : constructor HtmlResultSet(java.lang.String, java.sql.Connection) not found in class HtmlResultSet at line 42, column 34".
    Can anyone shed any light on this.

    Looks like you are passing a string (SELECT * FROM USERS) instead of passing a ResultSet. Try passing a Resultset.

  • Trying to display results from access database query on a JSP

    Seem to be having real difficulty with this one, i keep getting a null pointer exception :(. Wondered if anyone could point me to any examples of displaying the results on jsp. The database is connected, as i can display the query on netbeans, but just not on a jsp.

    I think it would be good if we had a section in these forums for pre-canned answers to the same questions that come up again and again. It would save time.
    Here is a rough outline for using JSP:
    * Read a JSP book.
    * The JSP page (View in MVC) should get all the data it needs to display from a useBean and/or request.getAttribute().
    * The JSP page should not have any business logic. Its purpose is to display data only (and have some submit buttons such as 'update').
    You can do some basic client side validation using javascript if you want. Because there is no business logic in it, you can easily debug
    your code in the servlet or business logic. You can't set breakpoints in JSP and examine data easily.
    * When you click the submit button, all data from <input type="text" tags, etc is put into request scope via name/value pairs.
    * Submit the JSP page <form tag to a servlet (Control in MVC).
    * The servlet reads the name/value pairs of data from the JSP page via request.getParameter()
    * The servlet should then instansiate a business object (Model in MVC), passing the data it got from the page to the business logic.
    Example: ProcessPage processPage();
    if(request.getParameter("updateButtonClicked"))
    processPage.updateData(data from the jsp page)
    * The business logic should instansiate a separate database object (DAO) to get data to/from the database. Business logic should not have sql in it.
    Business logic should not generate html. Business logic should not have request objects in it.
    * The business logic should return data to the servlet that in turn will put it in request scope via request.setAttribute() so the JSP page can draw itself.
    * The servlet should then call up the approprate JSP page.

  • Display results from dynamic query created and executed inside procedure

    Hi;
    I have created this code:
    CREATE OR REPLACE PROCEDURE RunDynamicQuery(Var1 IN VARCHAR2, Var2 IN VARCHAR2, VAR3 IN VARCHAR2) AS
    -- Do something
    -- That ends up with a variable holding a query.... (just an example)
    MainQuery :='select sysdate from dual';
    end RunDynamicQuery;
    How can I run this procedure and see the result on the dymanic query generated inside it?
    BEGIN
    compare_tables_content('VAR1','VAR2','VAR3');
    END;
    Expected Output for this given example:
    20-05-2009 11:04:44 ( the result of the dymanic query inside the procedure variable MainQuery :='select sysdate from dual';)
    I tested with 'execute immediate':
    CREATE OR REPLACE PROCEDURE RunDynamicQuery(Var1 IN VARCHAR2, Var2 IN VARCHAR2, filter IN VARCHAR2) AS
    -- Do something
    -- That ends up with a variable holding a query.... (just an example)
    MainQuery :='select sysdate from dual';
    execute immediate (MainQuery );
    end RunDynamicQuery;
    BEGIN
    compare_tables_content('VAR1','VAR2','VAR3');
    END;
    Output:"Statement processed'' (no sysdate displayed ! )
    Please consider that the collums in the query are always dynamic... PIPELINE Table would not work because I would need to define a container, example:
    CREATE OR REPLACE TYPE emp_tabtype AS TABLE OF emp_type;
    FUNCTION RunDynamicQuery (p_cursor IN sys_refcursor)
    RETURN emp_tabtype PIPELINED
    IS
    emp_in emp%ROWTYPE;
    BEGIN
    LOOP
    FETCH p_cursor
    INTO emp_in;
    EXIT WHEN p_cursor%NOTFOUND;
    PIPE ROW (...)

    That would be a nice solution, thanks :)
    ''For now'' I implemented like this:
    My dynamic query now returns a single string ( select col1 || col2 || col3 from bla)
    This way I don't have dynamic collumns issue, and from business side, this ''string'' format works for them.
    This way I can use the pipelines to get the result out...
    OPEN myCursor FOR MainQuery;
    FETCH myCursor
    INTO myRow;
    WHILE (NOT myCursor%notFound) LOOP
    PIPE ROW(myRow);
    FETCH myCursor
    INTO myRow;
    END LOOP;
    CLOSE myCursor;

  • Trouble displaying results from a database call

    Hi Everyone,
    I have written a JSP page that sends and receives information to a MySQL database. It is not completely functional unfortunately. The first section of the page that is responsible for updating a database table works fine. However when I go to retrieve information from the same database table something is going astray.
    I feel that I am doing something wrong with regard to the ResultSet object. Please see the bottom of the code section below. Ultimately this code only displays beach_percent as Zero, no matter how many entries there are in the database table for the corresponding value of Beach & Sea Stamps.
    <%@ page import="javax.servlet.*" %>
    <%@ page import="javax.servlet.http.*" %>
    <%@ page import="java.sql.*" %>
    <%
         Connection connect = null;
         Statement state = null;
         ResultSet rs = null;
         Class.forName("com.mysql.jdbc.Driver").newInstance();
         String password = "theOne";
         String url = "jdbc:mysql://localhost/survey_database";
         String user = "David";
         connect = DriverManager.getConnection(url, user, password);
         state = connect.createStatement();
         if(request.getParameter("radiobutton") != null)
              String enter_text = "insert into craft_survey values('";
              enter_text = enter_text.concat(request.getParameter("radiobutton"));
              enter_text = enter_text.concat("')");
              rs = state.executeQuery(enter_text);
         else
              pageContext.forward("craftSurvey.jsp");
         rs = state.executeQuery("SELECT stamp FROM craft_survey");
         int beach = 0;
         int bear = 0;
         int christmas = 0;
         int country = 0;
         int easter = 0;
         int faux = 0;
         int floral = 0;
         int heart = 0;
         int phrase = 0;
         int special = 0;
         int total = 0;
         while(rs.next())
              String type = rs.getString("stamp");
              if(type.equals("Beach & Sea Stamps"))
                   beach++;
                   total++;
              else
              if(type.equals("Bear & Cuddly Stamps"))
                   bear++;
                   total++;
              else
              if(type.equals("Christmas Stamps"))
                   christmas++;
                   total++;
              else
              if(type.equals("Country & Garden Stamps"))
                   country++;
                   total++;
              else
              if(type.equals("Easter Stamps"))
                   easter++;
                   total++;
              else
              if(type.equals("Faux Postage"))
                   faux++;
                   total++;
              else
              if(type.equals("Floral Stamps"))
                   floral++;
                   total++;
              else
              if(type.equals("Heart & Romance Stamps"))
                   heart++;
                   total++;
              else
              if(type.equals("Phrase & Wording Stamps"))
                   phrase++;
                   total++;
              else
              if(type.equals("Special Occasion Stamps"))
                   special++;
                   total++;
         int beach_percent = 0;
         int bear_percent = 0;
         int christmas_percent = 0;
         int country_percent = 0;
         int easter_percent = 0;
         int faux_percent = 0;
         int floral_percent = 0;
         int heart_percent = 0;
         int phrase_percent = 0;
         int special_percent = 0;
         if(beach > 0)
              beach_percent = (beach / total) * 100;
         if(bear > 0)
              bear_percent = (bear / total) * 100;
         if(christmas > 0)
              christmas_percent = (christmas / total) * 100;
         if(country > 0)
              country_percent = (country / total) * 100;
         if(easter > 0)
              easter_percent = (easter / total) * 100;
         if(faux > 0)
              faux_percent = (faux / total) * 100;
         if(floral > 0)
              floral_percent = (floral / total) * 100;
         if(heart > 0)
              heart_percent = (heart / total) * 100;
         if(phrase > 0)
              phrase_percent = (phrase / total) * 100;
         if(special > 0)
              special_percent = (special / total) * 100;
    %>
    <html>
    <head>
    <title> Craft Stamp Survey Results </title>
    </head>
    <body background="#ffffff">
    <h1> Craft Stamp Survey Results </h1>
    <table width="100%">
         <tr align="center">
         <td><img src="green_bar.jpg" height="20" width="<%=beach_percent *3%>"></td>
            <td>Beach & Sea Stamps</td>
            <td><%=beach_percent%></td>
    </tr>
    </table>
    </body>
    </html>Any help with getting this page to display anything other than zero will be great appreciated.
    Thanks
    David

    Hi,
    One reason could be of spaces .Before checking in the loop use trim function on the data retrieved from the database. You can also debug using System.out.println.
    Also just a suggestion - it is always a good coding practice to declare the variablse outside the loop. Don't declare the variables within a for loop.

  • Dificulty in displaying results from 2 tables

    Hi Experts,
    I have created a form that needs to display 2 different tables in the form. However, the second table only shows the results after all the records from the first are listed. I need to show both the tables in page 1 and continue to show the records in the succeeding pages. I have put the tables each in their different subforms and enclosed them in another subform but the entries from table 2 still does not show. Could you tell me what am I missing?
    Thanks and more power.
    Regards,
    Rare

    Hi,
    What is the cardinality of the nodes that these tables are mapped to?
    Is it 1..n or 0..n?
    If it is 0..n then this is where the problem may be..
    Try setting the minimum count of the second table to 1 in the binding tab in the livecycle designer..
    Also, make sure the paginatinof the two sub forms is set to Flowed..
    Hope this helps.
    Rgds, Amith

  • Want to display results from database pagewise ?

    I have 500 records in the sql server 2000 then i query and retrieve them in a resultsets. and then i want to display 10 records per page having the facility to navigate to the Previous and Next Record also going to first and the last record.
    like we are using when we navigate from this forum
    FIRST PREVIOUS 1 2 3 4 5 6 7 8 9 10 NEXT LAST
    secondly if their is a possiblity their should be a search page to to specific page like this
    Go To this Page (Textfield)
    third thing when i am on first record the it shouldnt show PREVIOUS button and when it is in the last it should not show NEXT.
    this thing should be done by Using JSP , Servelets and Beans...
    and PLEASE DONT SAY THAT IT HAS ALREADY BEEN ASK IF SO TELL ME THE LINK BECAUSE I CANT FIND ANYWHERE IN THE FORUM SO PLEASE TRY TO PROVIDE THE SOURCODE OR ATLEAST A REFERENCE FOR IT.

    for your task there is nice keyword in MySQL:
    LIMIT [offset,] rows
    maybe MSSQL has something similar...
    though i haven't seen such a keyword in oracle nor postgre... nor mssql (but i haven't looked for it from there...)
    one way would be to skip first X results in resultset... in PyML i have used method .skip(count) for skiping count rows, but i'm not sure that in java there is equivalent for that, so you might have to just call ResultSet.next() for count times, and then ten more times to get desired data for your page.

  • Displaying results from a database query using servlets

    I have this HTML form where users can search a MS Access database by entering a combination of EmployeeID, First name or last name. This form invokes a Java Servlet which searches the database and displays the results as an HTML page. I am giving the user the choice of displaying 3, 5 or 10 results per page. I want to know how to do that using servlets. If a particular search results in 20 results, the results should be displayed in sets of 3, 5 or 10 depending on the user's choice. If the user makes a choice of 5 results per page then 4 pages should be displayed with a "next" and "previous" button on each page. I want to know how this can be done.

    Arun,
    I'm not sure how to do this using JSP as I have not worked on JSP.
    But I can give you a hint on how to do this within normal java class as I've used this in my current project.
    In your core class/bean that generates the entire resultset, you need to run a loop that will scan through the desired number of records in the resultset.
    To do this, you have to have skip and max parameter in your URL.
    Somthing like http://server.com/myservlet?skip=0&max=10 to display first 10 records, http://server.com/myservlet?skip=10&max=10 to display next 10 records. The <next>parameter would be fed in by the user by a simple form in your web-page. If you need to hold this <max-num-of-recs-per-page> param, you can store it in a cookie (since this is nothing crucial piece of info, don't need to use session obj etc...cookie will do) and get the value each time you display the resultset.
    So, essentially, suppose you are at the first page and you wish to show 10 recs at a time. The link for "Next" button would be http://server.com/myservlet?skip=10&max=10
    when at the second page, you'll have
    "priv" button as http://server.com/myservlet?skip=0&max=10 and
    "next" button as http://server.com/myservlet?skip=20&max=10 and so on...
    hope this makes sense..
    Shantanu

  • Smart forms not displaying result from sub routine

    I am working on a smart form and need to display the description of the fabric code. Under Form Routines, I create a sub routine
    FORM fcc_values USING gv_fabrictext.
    which is supposed to store the description in gv_fabrictext. GV_FABRICTEXT has been declared in global data as char64. Then I call prior to displaying my table as
    perform fcc_values using gv_fabrictext.
    And then insert the field &gv_fabrictext& in cell but this does not display any result
    I know for sure that this sub routine works as I have tested it separately as a test program. Any ideas?

    1. put break point at ssf_function madulename and check field value.
    or
    2 fm_name export parameter ur not mentioned
    or
    3 global variable not defined properly
    go through above. still if u didnt get
    need program where the problem to find.
    Message was edited by:
            Deepa KN

  • Problem displaying results from a SQL database

    Hey everyone,
    So I am basically fairly new to coding, i am doing a tutorial i found on the web and trying to implement into my own. I have gotten so far in it and now have struck a problem, when i search for a item in a database it wont find it and a previous problem i had was that it was displayin all the records instead of the searched records. Anyway here is my code and i would greatly appreciate any help as i am stuck on it for weeks now trying to change is around and its really disheartening. P.S. The link to the tutorial if its any help is:http://www.sebastiansulinski.co.uk/web_design_tutorials/tutorial/9/link_exchange_system_wi th_dreamweaver_cs3
    Thanks
    Frank
    <?php require_once('../Connections/cbdb.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    $maxRows_rsStock = 20;
    $pageNum_rsStock = 0;
    if (isset($_GET['pageNum_rsStock'])) {
      $pageNum_rsStock = $_GET['pageNum_rsStock'];
    $startRow_rsStock = $pageNum_rsStock * $maxRows_rsStock;
    mysql_select_db($database_cbdb, $cbdb);
    // Search engine functionality
    if ($_GET['make'] || $_GET['model']) {
    $key = $_GET['make'];
    $categ = $_GET['model'];
    $query_rsStock = "SELECT * FROM stock WHERE stock.model LIKE '%$make%' AND stock.model LIKE '%$model%' ORDER BY stock.date DESC";
    } else {
    $query_rsStock = "SELECT * FROM stock ORDER BY date DESC";
    $query_limit_rsStock = sprintf("%s LIMIT %d, %d", $query_rsStock, $startRow_rsStock, $maxRows_rsStock);
    $rsStock = mysql_query($query_limit_rsStock, $cbdb) or die(mysql_error());
    $row_rsStock = mysql_fetch_assoc($rsStock);
    if (isset($_GET['totalRows_rsStock'])) {
      $totalRows_rsStock = $_GET['totalRows_rsStock'];
    } else {
      $all_rsStock = mysql_query($query_rsStock);
      $totalRows_rsStock = mysql_num_rows($all_rsStock);
    $totalPages_rsStock = ceil($totalRows_rsStock/$maxRows_rsStock)-1;
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/admin.dwt.php" codeOutsideHTMLIsLocked="false" -->
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <!-- InstanceBeginEditable name="doctitle" -->
    <!-- InstanceEndEditable -->
    <link href="../style/admin_style.css" rel="stylesheet" type="text/css" media="screen" />
    <!-- InstanceBeginEditable name="head" --><title>Stock List</title>
    <script type="text/javascript">
    function tmt_confirm(msg){
    document.MM_returnValue=(confirm(unescape(msg)));
    </script>
    <!-- InstanceEndEditable -->
    </head>
    <body>
    <div id="wrapper">
    <div id="header"><p>Admin</p></div>
    <div id="navigation">
    <ul id="mainav">
    <li><a href="stock_list.php">List of stock</a></li>
    <li><a href="stock_add.php">Add new stock</a></li>
    <li><a href="make_add.php">Makes</a></li>
    <li><a href="logout.php">Logout</a></li>
    <li id="front"><a href="C:\xampp\htdocs\CarBreakers" target="_blank">front</a></li>
    </ul>
    </div>
    <div id="container"><!-- InstanceBeginEditable name="Content" -->
      <p id="ptitle">Stock</p>
      <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get" id="forminsert">
      <table border="0" cellspacing="0" cellpadding="0" id="tblinsert">
      <caption>
        Search for Stock
      </caption>
      <tr>
        <th><label for="keyword">Make:</label></th>
        <td><input type="text" name="make" id="make" /></td>
        <th><label for="model">Model:</label></th>
        <td><input type="text" name="model" id="model" /></td>
        <td><input type="submit" id="button" value="Submit" /></td>
      </tr>
    </table>
      </form>
      <?php if ($totalRows_rsStock > 0) { // Show if recordset not empty ?>
          <?php if ($totalRows_rsStock == 0) { // Show if recordset empty ?>
      <p>Sorry, there are no records matching your searching criteria.</p>
      <?php } // Show if recordset empty ?>
    <table border="0" cellpadding="0" cellspacing="0" id="tblrepeat">
        <tr>
          <th width="63" scope="col">Make</th>
          <th width="67" scope="col">Model</th>
          <th width="59" scope="col">Year</th>
          <th width="79" scope="col">Engine cc</th>
          <th width="56" scope="col">Fuel</th>
          <th width="59" scope="col">Doors</th>
          <th width="56" scope="col">Body</th>
          <th width="104" scope="col">Arrival Date</th>
          <th width="51" scope="col">Edit</th>
          <th width="83" scope="col">Remove</th>
        </tr>
        <?php do { ?>
          <tr>
            <td><?php echo $row_rsStock['make']; ?></td>
            <td><?php echo $row_rsStock['model']; ?></td>
            <td><?php echo $row_rsStock['year']; ?></td>
            <td><?php echo $row_rsStock['cc']; ?></td>
            <td><?php echo $row_rsStock['fuel']; ?></td>
            <td><?php echo $row_rsStock['doors']; ?></td>
            <td><?php echo $row_rsStock['body']; ?></td>
            <td><?php echo $row_rsStock['date']; ?></td>
            <td><a href="stock_edit.php?id=<?php echo $row_rsStock['stockId']; ?>">Edit</a></td>
            <td><a href="stock_remove.php?id=<?php echo $row_rsStock['stockId']; ?>" onclick="tmt_confirm('Are%20you%20sure%20you%20want%20to%20perform%20this%20action?');ret urn document.MM_returnValue">Remove</a></td>
          </tr>
          <?php } while ($row_rsStock = mysql_fetch_assoc($rsStock)); ?>
    </table>
      <?php } // Show if recordset not empty ?>
    <!-- InstanceEndEditable --></div>
    <div id="footer"><p>© <a href="http://www.blablabla.com/" title="Web Designer" target="_blank">Web Design</a></p></div>
    </div>
    </body>
    <!-- InstanceEnd --></html>
    <?php
    mysql_free_result($rsStock);
    ?>

    In your code, you have this -
    // Search engine functionality
    if ($_GET['make'] || $_GET['model']) {
    $key = $_GET['make'];
    $categ = $_GET['model'];
    $query_rsStock = "SELECT * FROM stock WHERE stock.model LIKE '%$make%' AND stock.model LIKE '%$model%' ORDER BY stock.date DESC";
    } else {
    $query_rsStock = "SELECT * FROM stock ORDER BY date DESC";
    The "else" part of the "if" block is what is selecting ALL the records -
    $query_rsStock = "SELECT * FROM stock ORDER BY date DESC";
    This means that the "if" part of the "if" block is always failing.  When does it fail?  Whenever you have not passed a URL variable for either "make" or "model".  Are you sure you are correctly passing that variable?

  • Display results seperated by comma's

    Hi
    Just wondering if there was a way to display results from seperate rows in one text box where the results are seperated by comma's?
    =First(Fields!ClientId.Value, "DataSet1")
    The example above will just show one ClientId however I would like to list all of them all like below
    C001,C002,C546,F546,H232
    Am I after Lookup/LookupSet?
    Any help appreciated.
    Cheers
    Cheers Chris

    One method is to create a hidden parameter ,make it allow Multiple values and set its default value to be same as dataset field value. Then you can simply use
    =Join(Parameters!ParameterName.value,",")
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Using JTables to display data from a text file

    How do I display data from a .txt file into a column inside a JTable?

    dont quite get the "vectors" part..
    by the way, my program is as follows
    * Damn Java ..
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import java.awt.Dimension;
    import java.awt.GridLayout;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    public class ScoreBoard extends JPanel {
    private boolean DEBUG = false;
    public ScoreBoard() {
    super(new GridLayout(1,0));
    String[] columnNames = {"Player's Name",
    "Time Completed",
    "$ Amount Earned $"};
    /* Object[][] data = {
    {"1",
    new Integer(5), new Integer(500)},
    {"2",
    new Integer(5), new Integer(3200)},
    {"3",
    new Integer(5), new Integer(1000)},
    {"4",
    new Integer(5), new Integer(100)},
    {"5",
    new Integer(5), new Integer(200)},
    final JTable table = new JTable(data, columnNames);
    table.setPreferredScrollableViewportSize(new Dimension(600, 90));
    if (DEBUG) {
    table.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    printDebugData(table);
    //Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);
    //Add the scroll pane to this panel.
    add(scrollPane);
    private void printDebugData(JTable table) {
    int numRows = table.getRowCount();
    int numCols = table.getColumnCount();
    javax.swing.table.TableModel model = table.getModel();
    System.out.println("Value of data: ");
    for (int i=0; i < numRows; i++) {
    System.out.print(" row " + i + ":");
    for (int j=0; j < numCols; j++) {
    System.out.print(" " + model.getValueAt(i, j));
    System.out.println();
    System.out.println("--------------------------");
    * Create the GUI and show it. For thread safety,
    * this method should be invoked from the
    * event-dispatching thread.
    private static void createAndShowGUI() {
    //Make sure we have nice window decorations.
    JFrame.setDefaultLookAndFeelDecorated(true);
    //Create and set up the window.
    JFrame frame = new JFrame("ScoreBoard");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //Create and set up the content pane.
    ScoreBoard newContentPane = new ScoreBoard();
    newContentPane.setOpaque(true); //content panes must be opaque
    frame.setContentPane(newContentPane);
    //Display the window.
    frame.pack();
    frame.setVisible(true);
    public static void main(String[] args) {
    //Schedule a job for the event-dispatching thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();
    and i want to display the player name from a textfile.txt to the player column instead of hardcoding it like above. Thanks!

  • How to configure search results web part to display results only after a query is generated from user?

    Hi All,
    I am crawling documents from a file server. I created a new content source and crawled the documents. All documents are crawled successfully.
    Then I went to my enterprise search center site collection and created a new result source. I have added the query to use above content source.
    After that, on a page I am trying to configure the search results web part to display documents using this result source. Now the problem is:
    It displays all the documents that are crawled without searching for anything. I mean first it should not display any results. If a user searches for something , then according to that search it should display results.
    Any idea how to do this in the web part? I am using SharePoint 2013 on premise enterprise edition. No code. Totally OOTB.

    Hi Mohan,
    What did you use for the Query text in the result source?
    I could reproduce this issue when I used Query text like: {searchTerms} Path:”http://sps2k13sp/sites/First/Shared%20Documents”
    Then I changed the Query to
    {?{searchTerms}
    Path:"http://sps2k13sp/sites/First/Shared%20Documents"}
    , then Search result web part didn’t return results without searching.
    So , check your result source, and use the Query like the above(adding "{?...}").
    I hope this helps.
    Thanks,
    Wendy
    Wendy Li
    TechNet Community Support

  • Display results of MySQL query from AMFPHP by ArrayCollection in AS3 (Flash CS4)

    Hi, i am using Flash CS4 (AS3) + AMFPHP + MySQL to do own flash frontend for Wordpress CMS.  Everything is going fine but i`ve got one problem. Problem with properly display of result of query in AS3 by using ArrayCollection.
    When i check my service in "amfphp/browser/" in web browser i`ve got this (with all needed data):
    (mx.collections::ArrayCollection)#0
    filterFunction = (null)
    length = 2
    list = (mx.collections::ArrayList)#1  
    length = 2     source = (Array)#2
    That is the reason that i suppose that service work fine.  Problem is when i try to display result in AS3. In actionscript i have got this:
    function getNewsListHandler(result:Object):void{
    trace(result);
    This function displays: [object Object].
    I know that "result" is an ArrayCollection type but i don`t know how to get rows and columns from this. I know that my data is there but i have no idea how to get it.
    Clarify: I don`t know how to get to Arrays and simple data variables which are in ArrayCollection.
    Could anyone help me with that problem. I would be gratefull
    P.S. I tried also change query type in service.PHP for mysql_fetch_query but in that case i`ve got only one row (not all data).

    Thanks for fast reply,
    arr_coll:ArrayCollection = new ArrayCollection ({col1:"data1",col2:"data2"}, {col1:"data3",col2:"data4"});
    you would get the data like
    var resultstr:String = arr_coll[1][1].col2;
    trace(resultstr);
    //results in data4
    could you explain me how it was happen (arr_coll[1][1].col2)? It`s not clear to me. I thought in this case rather something like this :
    var resultstr:String = arr_coll[1]['col2'];
    It should give me "data4". I know it wasn`t but i don`t understand ArrayCollection in level which is needed to use your advice in my case. Could you clarify "arr_coll[1][1].col2" a bit?
    What would it look like when you would have something like this:
    arr_coll:ArrayCollection = new ArrayCollection ({col1:"data1",col2:"data2"}, {col1:"data3",col2:"data4"},{col1:"data5",col2:"data6"},{col1:"data7",col2:"data8"});
    and you would want know f.e. position in ArrayCollection of  "data6". How would you code this? arr_coll[1][2].col2?

  • How do I display results (anywhere) from the SequenceFileLoad Step?

    I want to be able to display the results from the SequenceFileLoad Sequence after the Sequence has been loaded to a window in a customized version of the CVI Test Executive User Interface. I can't seem to find where this Sequence gets called from in the Process Model (breakpoints are ignored), assuming that is where I want to make my changes.

    There are 3 types of callbacks: Model, Engine and FrontEnd callbacks (see table 1-1 and table 6-4 of the TS 2.0 User Manual).
    What differentiates these types are
    1) Where the callback sequences are located.
    2) What calls the callback.
    The SequenceFileLoad callback is an engine callback. This means that it is called by the TS engine and not your model. You place the callback in the sequence file, for which upon opening, you want the callback to run.
    Since the engine is executing this callback you have no control over parameters that are passed into or out of the sequence. In addition, the file global and local variables of the executed SequenceFileLoad callback are lost when the execution completes.
    You could have the callback write the values of
    Locals.Result to a file or station globals so that the information is available after the execution completes. There are even temporary station globals (see Engine.TemporaryGlobals) that allow you to keep hidden station globals variables that does not get written to the StationGlobals.ini upon shutdown of your station. These hidden variables do not appear in the station global window.
    Attached is a starting point for you. When you open this sequence file the Load callback puts its results into a temporary (hidden) station global. When you run the MainSequence, a subsequence is called that replaces its results with those contained in the temporary station global. This only occurs if the global exists. The subsequence also deletes the temporary global. The results appear as the results of the sequence call step in the MainSequence.
    By the way, you enable tracing into the engine callbacks by checking the station option, "Trace Into Separate Execution Callbacks".
    Attachments:
    SeqFileLoadResults.seq ‏30 KB

Maybe you are looking for