campanal
asked on
problem with odbc_num_rows
hi everybody,
I have a problem with the count of the rows after a query.
I work with a DB MS Access and I know that odbc_num_rows doesn't work.
I thied this:
$sql1 = "SELECT COUNT(*) FROM contribuente where con_numero_controllo in (".$sql.") as righe";
$sql_result = odbc_prepare($cn,$sql1) or die("ERROR");
odbc_execute($sql_result) or die("ERROR");
$rc = odbc_fetch_into($sql_resul t, $my_array);
echo ("Total rows: " . $my_array[0]);
odbc_free_result($sql_resu lt);
the subselect $sql is:
$sql="select con_numero_controllo as N_controllo,con_numero_reg istro as N_registro, con_cognome as Cognome, con_nome as Nome,con_data_nascita as Data_nascita
from contribuente
where (1=1) and (con_cognome like'ca%')";
con_cognome is a choice that the uses makes. for example i write "ca" and it gives me back the all name that gegin with ca.
there is something wrong in the the subselect bacause it can't perform it.
Can anyone help me please..
thanks in advance
I have a problem with the count of the rows after a query.
I work with a DB MS Access and I know that odbc_num_rows doesn't work.
I thied this:
$sql1 = "SELECT COUNT(*) FROM contribuente where con_numero_controllo in (".$sql.") as righe";
$sql_result = odbc_prepare($cn,$sql1) or die("ERROR");
odbc_execute($sql_result) or die("ERROR");
$rc = odbc_fetch_into($sql_resul
echo ("Total rows: " . $my_array[0]);
odbc_free_result($sql_resu
the subselect $sql is:
$sql="select con_numero_controllo as N_controllo,con_numero_reg
from contribuente
where (1=1) and (con_cognome like'ca%')";
con_cognome is a choice that the uses makes. for example i write "ca" and it gives me back the all name that gegin with ca.
there is something wrong in the the subselect bacause it can't perform it.
Can anyone help me please..
thanks in advance
ASKER
But I only want the number of rows because if the result is > 2 then I show a messagge..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks for the help
$sql1 = "SELECT COUNT(*) as righe FROM contribuente where con_numero_controllo in (".$sql.")";
but if you want to get all the results and put them in an array you use
$sql1 = "SELECT * FROM contribuente where con_numero_controllo where (1=1) and (con_cognome like'ca%')";
this way you are sure you are getting all the rows (of data) in your table