Jump to content

[SOLVED] quick question


paulman888888

Recommended Posts

No that query is wrong. You should use

if(isset($_GET['id']) && is_numeric($_GET['id']))
{
    $id = $_GET['id'];
    $result = mysql_query("SELECT * FROM downloads WHERE id = '$id'"); 

    if(mysql_num_rows($result) > 0)
    {
        $row = mysql_fetch_assoc($result);

        echo '<pre>' . print_r($row, true) . '</pre>';
    }
    else
    {
        echo $id . ' does not exist!';
    }
}

? Pardon

 

I just want to echo out that row from my mysql database

I get this error when i try running it.

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/www/somesite.com/info.php on line 17

and line 17 is this

while($row = mysql_fetch_array( $result ))

and the whole php code is this

<?php $id = $_GET['id'];
$result = mysql_query("SELECT * FROM friends ROW $id WHERE id = ASC"); 

echo '<table border="1" width="550">';
echo "<tr bgcolor='#FFFFFF'><th>ID</th><th>Name</th><th>Location</th><th>GO</th><th>Comments</th></tr>";
while($row = mysql_fetch_array( $result ))
{
    // alternate class
    $class = ($i%2 == 0) ? '#00FF00' : '#00FF00';
$class2 = ($i%2 == 0) ? '#CCCCCC' : '#999999';

// Print out the contents of each row into a table
echo "<tr bgcolor='".$class2."' onmouseover=\"this.style.backgroundColor = '".$class."';\" onmouseout=\"this.style.backgroundColor = '".$class2."';\">";
echo '<td><a href="info.php?id='.$row['id'].'">'.$row['id']."</a></td>\n";
echo "<td>".$row['name']."</td>";
echo "<td>".$row['location']."</td>";
echo '<td><center><a href="'.$row['location'].'"><img src="Images/downloadsm.png" /></a></center></td>';
echo "<td>".$row['Comments']."</td>";
echo "</tr>";
    $i++; // increment counter
}

echo "</table>";


?>

 

Thankyou for all the help

Archived

This topic is now archived and is closed to further replies.

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