php - Do I always need to use mysql_fetch
I seem to always use these lines when i am doing a select in PHP
$product_query = "Select ProductID from productinfo where PartName = '".mysql_real_escape_string($data)."'"; $product_result = mysql_query($product_query) ; $product = mysql_fetch_assoc($product_result) ; $my_product_id = $product['ProductID'];
This works but it clutters the page so i was wondering if there an way to do this in a more concise manner
You can make your own class which just returns the data after you give it the query.
You can also use PDO, which has a similar, cleaner and safer API: