mysql - Retrieve Data from Database by Passing an ID, c++ -


i trying fetch data database giving id number. database has 2 columns, first id, , second image path. if pass id=3, should return path corresponding id.

i have tried that, stuck @ query.

mysql_query (conn, "select * table" ); res = mysql_use_result(conn); row = mysql_fetch_row(res) id = atoi(row[0]); path = row[1]; printf("id: %i", id);  printf("image path: %s", path); 

please help:)

i think question not clear. first case, each row want display id/path:

mysql_query (conn, "select * table" ); res = mysql_use_result(conn); while (row = mysql_fetch_row(res)) {   id = atoi(row[0]);   path = row[1];   printf("id: %i", id);   printf("image path: %s", path); } 

other possibility, want 1 row because know id looking for. can decide retrieve missing column like:

mysql_query (conn, "select path table id=id" ); 

in more complicated cases, lets if may have multiple rows, can keep first 1 example adding top condition in query. in cases need think on returned real.

i didn't test code wrote, edited bit posted (just fair ^^)


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -