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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.