Dear Matthew,
> PHP
> -------
> $res = mysql_real_query($mysql,"SELECT col1, col2 FROM
> table"); while($row = mysql_fetch_row($res)) {
> print $row['col1'];
> print $row['col2'];
> }
>
> Is the only way/best way to do the above in C by using a
> nested for-loop?
> Ex:
>
> fields = mysql_fetch_fields(res);
> while((row=mysql_fetch_row(res)) {
> for(x=0;x<numFields;x++) {
> sprintf(output, "Column name: %s Column Value:
> %s\n", fields[x].name, row[x]);
> }
> }
>
> Seems painful and extra-loopy to do it in C. Is there a better way?
the php-code does not exactly the same than the lines in c.
The only difference was to add a call to mysql_store_result ().
But you may put the first two calls into a function to have it
in one row.
mysql_real_query (pMySQL, ...);
res = mysql_store_result (pMySQL);
while((row=mysql_fetch_row(res)) {
printf("%s%s", row[1], row[2]);
}
Regards,
TomH
--
PROSOFT EDV-Loesungen GmbH & Co. KG phone: +49 941 / 78 88 7 - 121
Ladehofstrasse 28, D-93049 Regensburg cellphone: +49 174 / 41 94 97 0
Geschaeftsfuehrer: Axel-Wilhelm Wegmann [EMAIL PROTECTED]
AG Regensburg HRA 6608 USt.183/68311 http://www.proSoft-Edv.de
--
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]