MySQL php quesry question

Discussion in 'MySQL' started by tintumon, Jul 24, 2010.

  1. #1
    Hi,
    I will try my best to explain my question. I have a table 'abc' and I want to include queries from column '3' in a php code. I need help please.

    ---------
    | 1 | 2 | 3|
    |--|--|--|
    | a | b | c |
    |--|--|--|
    | d | e | f |
    |--|--|--|

     
    tintumon, Jul 24, 2010 IP
  2. jemagee

    jemagee Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I'd love to help you but I'm unable to understand the question. Is it a PHP question of a MySQL question you are truly asking?
     
    jemagee, Jul 24, 2010 IP
  3. Deacalion

    Deacalion Peon

    Messages:
    438
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I don't really understand your question, what is this table storing? HTML, PHP, more SQL queries?
    You first need to retrieve the data from the table before you can use it... you are querying it without fetching the rows.

    Example:
    
    <?php
        $query = 'SELECT 1, 2, 3 FROM abc';
        $req = mysql_query($query);
        $row = mysql_fetch_assoc($req); 
        
        $header='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>'.$row['3'] <-------HERE
    ?>
    
    PHP:
     
    Deacalion, Jul 25, 2010 IP
  4. saadi123

    saadi123 Well-Known Member

    Messages:
    196
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #4
    You first need to fetch the row which you want to show just as DEACALION has shown how to do it. Secondly you can also use the MYSQL WHERE keyword to limit your query to include only your desired record and not all the records from the data base.
    Third .$3 won't generate anything in fact using $row['3'] would be more appropriate.
     
    saadi123, Jul 28, 2010 IP