Jump to content

retrieving specific data from mySQL using PHP


AhmadYousef

Recommended Posts

Hi guys ..

 

please help me .. I don't know how to do this and I tried but there were no satisfied  results..

 

I want to retrieve a Title (ing_title) from a database called k_db2 , in a table called content_langs 

depending on its ID , which called ing_contID

 

example: if ing_contID=1 , then show the ing_title with this id ing_contID

 

the above code should be in a php file ..

 

then I want to include this php file inside the header of my website..

by importing the ing_contID from the database and depending on it the title should be shown..

 

 

I really tried but I couldn't find any solution .. :(

 

if you could help me in the first part of this problem I'll be glad ..

First thing to do is connect to your database server and set the default database

http://php.net/manual/en/mysqli.construct.php

 

Then you you need to query your database table and get the result set

http://php.net/manual/en/mysqli.query.php

 

The query you need will be "SELECT ing_title FROM content_langs WHERE ing_contID = 1"

 

Next, get the record from the result set

http://php.net/manual/en/mysqli-result.fetch-assoc.php

 

Examples on the above page links should help you

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.