mysql select a certain colum

Discussion in 'Programming' started by dawilster, Oct 10, 2008.

  1. #1
    i have a table called
    links
    Code (markup):
    and inside this table are the columns
    id 	name 	link 	type
    Code (markup):
    What i want to do is when i request the id it will display the rest of the column associated with that id.

    thanks
     
    dawilster, Oct 10, 2008 IP
  2. dannywwww

    dannywwww Well-Known Member

    Messages:
    804
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    110
    #2
    I just quickly wrote this up. (not tested) simply selects the column data requested by the ID.

    so... file.php?ID=the_id
    
    
    <?
    // clean the requested ID.
    $ID = abs((int) $_GET['ID']);
    
    // get the data using the where cluase from the requested ID.
    $q = mysql_query("SELECT * FROM links WHERE id='$ID'") or die(mysql_error());
        echo "<table>
                <tr>
                    <th>Link ID</th>
                    <th>Name</th>
                    <th>Link</th>
                    <th>Type</th>
                </tr>    
                ";
        while($cl = mysql_fetch_array($q)){
        echo "    <tr>
                    <td>".$cl['id']."</td>
                    <td>".$cl['name']."</td>
                    <td>".$cl['link']."</td>
                    <td>".$cl['type']."</td>
                </tr>";        
        }
        echo "</table>";
    ?>
    
    
    PHP:
    Hope it helps :)
     
    dannywwww, Oct 10, 2008 IP