I am able to get a c function to INSERT and UPDATE a cell on a table, but I am having issues to be able to get a value from a cell and have it saved as a variable that I can use to compare and do calculations on it. Thank you in advance.
void MIA_get_data_temperature()
{
MYSQL_RES *query_results = mysql_store_result(conn);
MYSQL_ROW row; //This will declare row variable
//int total_rows = mysql_num_rows(query_results);
int num_fields = mysql_num_fields(query_results);
int i;
char buffer[256]; // Setting buffer for query string
const char *query = "SELECT Temperature FROM `temperature` WHERE Mode='Current_Temperature'";
//snprintf() - safer thatn sprint USE THIS
//checking to make sure query string is not to large for buffer & formatting query to get passed
if (snprintf(buffer, sizeof(buffer), query) >= sizeof(buffer))
{
printf("Issue with Buffer \n");
exit (-1);
}
//Reading from MySQL Table
if(mysql_query(conn, buffer) !=0)
{
fprintf(stderr, "%s\n", mysql_error(conn));
exit (-1);
} else {
while((row = mysql_fetch_row(query_results)) !=0)
{
for (i = 0; i < num_fields; i++)
{
??? Saving Result as a variable
}
}
}
}