Note that there are some explanatory texts on larger screens.

plurals
  1. POretrieve data from sql table through c++
    primarykey
    data
    text
    <p>as the title says i want to do the following:</p> <p>I created (in sql) a table "radiation" which is :</p> <p><img src="https://i.stack.imgur.com/Uo1Es.png" alt="enter image description here"></p> <p>Now, i want from c++ to be able to ask the user "Give an element " and if the user gives for example "I" then retrieve the "halftime" field for example.</p> <p>The c++ code is :</p> <pre><code>#include &lt;iostream&gt; #include &lt;cstdio&gt; #include &lt;cstdlib&gt; #include &lt;cmath&gt; #include &lt;sys/time.h&gt; #include &lt;mysql/mysql.h&gt; using namespace std; int main() { MYSQL_RES *result; MYSQL_ROW row; MYSQL *connection, mysql; const char* server="127.0.0.1"; const char* user ="****"; const char* password="****"; const char* database="***"; int state; mysql_init(&amp;mysql); connection = mysql_real_connect(&amp;mysql,server,user,password,database,0,0,0); if (connection == NULL) { cout&lt;&lt;mysql_error(&amp;mysql); return 1; } state = mysql_query(connection, "SELECT * FROM radiation"); if (state !=0) { cout &lt;&lt;mysql_error(connection); return 1; } result = mysql_store_result(connection); row=mysql_fetch_row(result); string name; cout &lt;&lt;"\nGive the name : "&lt;&lt;endl; cin &gt;&gt;name; cout &lt;&lt; "\nThe halftime for "&lt;&lt;name &lt;&lt; " is "&lt;&lt;**row[2]**-&gt;here i want to extract the analogous filed &lt;&lt;" hours"; //} mysql_free_result(result); mysql_close(connection); return 0; } </code></pre> <p>I know only the basics from sql , i don't know how difficult is to do the above.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload