Nout - Zon Executive Posted January 11, 2011 Report Share Posted January 11, 2011 Hey Guys, I now that you can use mysql_num_rows but with phpVMS theres the custom mysql connect syntax that makes everything a lot cleaner. i.e. DB::get_results($query) How do I count rows? (i.e. count the number of schedules with B747-400 departing EHAM) Cheers, Nout Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted January 12, 2011 Administrators Report Share Posted January 12, 2011 DB::get_row('SELECT COUNT(*) FROM .......'); Quote Link to comment Share on other sites More sharing options...
Nout - Zon Executive Posted January 12, 2011 Author Report Share Posted January 12, 2011 When I do the following: $query_count = "SELECT COUNT(*) FROM ".TABLE_PREFIX."schedules WHERE aircraft=".$aircraft->id." AND depicao='$location'"; $rowcount = DB::get_row($query_count); echo $rowcount; I get the error: Catchable fatal error: Object of class stdClass could not be converted to string in /Users/Nout/Desktop/ZE Site/core/templates/realschedulelite/realschedulelite_airport_details.tpl on line 56 What I have in place is a table of flights per airport which pilots can then book. Thus I use "foreach" to display a new table-row per flight. That works perfectly for any airport with more than one flight departing it. For an airport with only one flight departing it, the table is shown but above it theres an ugly error reading: Warning: Invalid argument supplied for foreach() in /Users/Nout/Desktop/ZE Site/core/templates/realschedulelite/realschedulelite_airport_details.tpl on line 133 So what I want is to count rows and if theres is only one applicable row I remove the foreach and use DB::get_row otherwise the foreach clause is used with DB::get_results. Cheers, Nout Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted January 12, 2011 Administrators Report Share Posted January 12, 2011 Ensure that: $aircraft->id Is a proper variable Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.