New Coder Posted July 15, 2008 Share Posted July 15, 2008 Hello all, I have the following code, but the odbc_num_rows always returns -1, therefore never showing the "no units stored" message. Doesn't odbc_num_rows function the same as mysql_num_rows?? <?php #connect to db $conn = odbc_pconnect('DB','',''); if(!$conn) {exit("Err:Conn"); } #collect variables from units page $id = $_POST['id']; #create queries $sql = "select * from contents where ID=$id"; #exe queries $result = odbc_exec($conn, $sql); if( !$result ) { exit ("ERR:exe"); } $num = odbc_num_rows ($result); if ($num !=0) { $list = "<table align=\"center\" border=\"0\" width=\"75%\">"; $list .= "<tr>"; $list .= "<th colspan=\"2\">Already stored</th>"; $list .= "</tr>"; $list .= "<tr>"; $list .= "<th>Content ID</th>"; $list .= "<th>Content</th>"; $list .= "</tr>"; #retrieve data while($rowodbc = odbc_fetch_array($result)) { $unit_no = $rowodbc["Unit_No"]; $unit_title = $rowodbc["Unit_title"]; $list .= "<tr>"; $list .= "<td>".$rowodbc["contents_id"]."</td>"; $list .= "<td>".$rowodbc["content"]."</td>"; $list .= "</tr>"; } $list .= "</table>"; #list details if matches found or display no matches found msg echo( "<h3>Unit No: ". $unit_no. "<br>Unit Title: ". $unit_title. "</h3>". $list ); } else { echo ("<br><center>No Units stored</center><br>"); } odbc_close( $conn ); odbc_free_result($result); ?> Many Thanks Link to comment https://forums.phpfreaks.com/topic/114857-odbc_num_rows/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.