Jump to content

MySql Query Help


scaryjello

Recommended Posts

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  :D

 

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

Link to comment
https://forums.phpfreaks.com/topic/183666-mysql-query-help/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/183666-mysql-query-help/#findComment-969674
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.