# Displaying SQL in a table

1. Nov 1, 2004

### ponjavic

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. Nov 1, 2004

### dduardo

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;
}

3. Nov 1, 2004

### ponjavic

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

4. Nov 1, 2004

### dduardo

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.

5. Nov 2, 2004

### ponjavic

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?

6. Nov 2, 2004

### chroot

Staff Emeritus
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