Page 1 of 1

MySQL Row Count PHP

Posted: Thu Feb 19, 2009 9:33 am
by tekhead2004
Hi all. Trying to figure out why my row count only returns a value of 1 although I know it should be returing more.

Code: Select all

 
$mySQL = "SELECT Pallet, puwo_number as 'Pickup Workorder', t_tag as 'T-Tag', Make, Model, serial_number as 'Serial Number' , comments as 'Comments', (Select description from dropdowns where tablename = 'pickups' and columnname = 'type' and value =pickups.type) as Type , Location, shipdate as 'Ship Date', CONCAT('<a href=http://www.fedex.com/Tracking?&cntry_code=us&clienttype=ivother&tracknumbers=' , Tracking_number,' target=new>',Tracking_number,'</a>') as 'Tracking Number', logged_by as 'Logged By', Edited_by as 'Edited By' from pickups, locations where pickups.locationid = locations.locationid";
        if (trim($_POST["criteria"]) != ""  && trim($_POST["choice"]) != "") {
            $mySQL .= " and (" . $_POST['choice'] ." = ";
            $mySQL .= " '".str_replace("\n" ,"' or ". $_POST['choice'] ."= '", trim(str_replace(", ","' or ".$_POST['choice'] ."= '", trim($_POST["criteria"]))))."')";
        }
        echo "MYSQL query made by variables: $mySQL <br><br>";
        $result = mysql_query ($mySQL) ;
        if (!$result)
        {
              die('Error: ' . mysql_error());
        }
        $count =  mysql_num_rows($result);
        
        $Output .= "Rows Returned (this using the dynamic:".$count."<br>";
 

Re: MySQL Row Count PHP

Posted: Thu Feb 19, 2009 10:37 pm
by Stryks
Well ... are you SURE that your query is in fact returning more than one result? I cant see any looping and outputting of the results so you can be sure. Try that and see how many results show vs. how many it tells you about.

Re: MySQL Row Count PHP

Posted: Fri Feb 20, 2009 3:29 am
by vmmene
echo your sql statement then run it on mysql it will give the exact results.