I've got a mysql query that should return a single cell

SELECT `download` FROM `images` WHERE `owner_un`='$owner' AND `url`='$url'

How would I echo the result of this?
Thanks for any help

Recommended Answers

All 4 Replies

There are code snippets in the PHP forum showing you how. Preferably the one using MySQLi or PDO.

In PHP (using mysql), fetching one result:

<?php
$q = "SELECT `download` FROM `images` WHERE `owner_un`='$owner' AND `url`='$url' LIMIT 1";
$rq = mysql_query($q);
$fetch = mysql_fetch_assoc($rq);

echo '<p>Result: ' . $fetch['download'] . '</p>';

Fetching all results:

<?php
$q = "SELECT `download` FROM `images` WHERE `owner_un`='$owner' AND `url`='$url' LIMIT 1";
$rq = mysql_query($q);

while($fetch = mysql_fetch_assoc($rq))
{
    echo '<p>Result: ' . $fetch['download'] . '</p>';
}

True, I'd also recommend using PDO/mysqli instead of just mysql :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.