scaryjello Posted December 2, 2009 Share Posted December 2, 2009 I am having trouble taking these Sql queries and turning them into PHP code. The format that I am suppose to follow by looks like the ones from this page http://www.w3schools.com/php/php_mysql_select.asp. Can anyone code these queries for me? it would be greatly appreciated SELECT * FROM Vehicle WHERE Color = 'black' SELECT v.model, v,year, v.color FROM vehicle v, suv s WHERE v.vin# = s.vin# AND v.year = 2006 and s.drive_train = 4 Quote Link to comment https://forums.phpfreaks.com/topic/183666-mysql-query-help/ Share on other sites More sharing options...
cags Posted December 2, 2009 Share Posted December 2, 2009 You've already coded the queries thats what you provided. You don't need to 'turn it into PHP' per se. You simply need to connect to the database using mysql_connect and mysql_select_db. Then use mysql_query to send the query to the database. For example... mysql_connect('host_name', 'username', 'password'); mysql_select_db('db_name'); $sql = " SELECT * FROM Vehicle WHERE Color = 'black' "; mysql_query($sql); You then simply use one of the other mysql_ functions to read through the data. Such as mysql_fetch_array or mysql_fetch_assoc. For more assistance we will need more information. Quote Link to comment https://forums.phpfreaks.com/topic/183666-mysql-query-help/#findComment-969674 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.