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!';
    }
}

Link to comment
Share on other sites

? 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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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