Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Displaying SQL in a table

  1. Nov 1, 2004 #1
    Let's say I'm communicating with a SQL (local) database using sqlite. How would i go about displaying this database as a table in a win32 program using either dev-c++ or MSVS++?
  2. jcsd
  3. Nov 1, 2004 #2


    User Avatar
    Staff Emeritus

    Don't you think SQL is overkill for a small basketball team? Why don't you just use a plain text file or xml? If you go the SQL route I don't think you'll ever finish your program.

    From my experience with SQL and PHP when you SELECT somthing you'll get some encoded data that you can iterate through. A PHP Example:

    Code (Text):

    $results = mysql_query('SELECT name FROM team');
    while( $name = mysql_fetch_assoc($results) ) { // mysql_fetch_assoc gets the next chunk of data from $results
    echo $name;
  4. Nov 1, 2004 #3
    seems as though sqlite can do the translation, I'm just wondering how to put it in some kind of grid table in a comfortable way
    for example SELECT * would return char** using sqlite
  5. Nov 1, 2004 #4


    User Avatar
    Staff Emeritus

    Your really confused aren't you? The gui toolkit you use will dictate how you enter information into a table. This isn't basic C++ we are talking about here. You really have to be confortable with object oriented programming. For example if you use QT this is how you would enter a value into a cell:

    Code (Text):

     for ( int row = 0; row < table->numRows(); row++ ) {
            for ( int col = 0; col < table->numCols(); col++ ) {
                table->setItem( row, col,
                    new QTableItem( table, QTableItem::WhenCurrent, QString::number( row * col ) ) );
    The code above goes through the whole table and fills in each cell with its repected col * row value. Row 0 Col 0 would have a 0, Row 1 Col 5 would have a 5, Row 2 Col 10 would have a 20, etc.
  6. Nov 2, 2004 #5
    I am confused about which toolkit to use. We wen't over this before, I am not going to use Qt so what other either toolkits or grid tables would you recommend?
  7. Nov 2, 2004 #6


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    There are a bunch of toolkits. The best ones, IMO, are Qt and GTK+. Qt is generally regarded as being superior, but it's a commerical product. GTK+ is free software.

    - Warren
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Discussions: Displaying SQL in a table
  1. Bit Display. (Replies: 6)

  2. SQL columns (Replies: 5)

  3. SQL Help? (Replies: 8)

  4. RGB display ? (Replies: 3)

  5. Display settings (Replies: 2)