Search code examples
phpmysqldatabasecell

How to get a particular cell from MySQL table using PHP?


I'm having a problem with getting a specific cell from database.

Here is what I've got:

So, how do I get only that last cell with URL using PHP and MySQL?


Solution

  • <?php
    
    $conn = mysql_connect('localhost', 'mysql_user', 'mysql_password');
    
    if (!$conn) {
        die('Could not connect: ' . mysql_error());
    }
    
    mysql_select_db('database');
    
    $result = mysql_query('select URL from table');
    
    if (!$result) {
        die('Query failed: ' . mysql_error());
    }
    
    echo mysql_result($result, 0); // outputs
    
    mysql_close($conn);
    
    ?>