php - trying to count entries in a database -


i'm trying count entries in database based on 2 basic criteria. returning blank result, though there results found. have idea doing wrong here? have tried many different ways , return no result. (if enter query directly in phpmyadmin returns result.)

$sql = "select count(*) total_count orderoption3detail orderdate='$orderdate' , studentid='$studentid'";  $numericalresult = mysql_query($sql, $con); $row = mysql_fetch_object($numericalresult); $totalorders1 =  $row->total_count; echo "my orders:" . $totalorders1;  

as others stated, make sure sanitize variables before go query.

$sql = "select * orderoption3detail orderdate = '" . $orderdate . "' , studentid = '" . $studentid . "'";  $sql_request_data = mysql_query($sql) or die(mysql_error()); $sql_request_data_count = mysql_num_rows($sql_request_data);  echo "number of rows found: " . $sql_request_data_count; 

that's need.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -