0

hello there I have PHP query that Fetch Records from a database with where condition I have four pages in WebSite I want to Fetch data from DataBase with where Condition Ever pages Fetch own Content From database Through link It's my query that's not work

Prefix already in config file

$prefix     = 'v1_';

$link = $p['link'] ;
    $data_query = $db->query("
        SELECT * FROM ".$prefix.$key." 
        WHERE "$p['link'] = $link "
      "); 

In WebSite pages are Define with key $x

$x = 'about';
$pages[$x]['title']  = 'About Us';
$pages[$x]['link']   = 'about_us';
$pages[$x]['source'] = 0;

and same variable and own info in both pages

$x = 'objects';
$x = 'services';

and I'm using this query in website its work fine but now I want to change that I mention above details

 $data_query = $db->query("
    SELECT * FROM ".$prefix.$key." 
    WHERE online = 1 ;
  ");

Any contributors to this post, I thank you for your help :)

2 Answers 2

0

Try this:

$data_query = $db->query("SELECT * FROM {$table} WHERE link = {$link}"); 
Sign up to request clarification or add additional context in comments.

Comments

0

you can use LIKE query

eg.

SELECT * <TABLE_NAME> WHERE COLUMN_NAME LIKE '<prefix>%'

For multiple where condition read this answere

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.