Jump to content

retrieving specific data from mySQL using PHP


AhmadYousef
Go to solution Solved by Barand,

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

Link to comment
Share on other sites

  • Solution

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

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.