How do you create a simple function to query the database? Mine isn't working!

boffblaft

New Member
I want to make a simple function that I can call on to query my database. I pass the "where" part of the query to it and in the code below, my $q variable is correct. However, what should I then do to be able to use the data? I'm so confused at how to do something I'm sure is extremely easy. Any help is greatly appreciated!\[code\]function getListings($where_clause){ $q = "SELECT * FROM `listings` $where_clause"; $result = mysql_query($q,$dbh); foreach (mysql_fetch_array($result) as $row) { $listingdata[] = $row; } return $listingdata;}\[/code\]
 
Back
Top