0

Hi geeks,
I am working on a query string but I am kinda stuck with the code, I guess this is so cos am a PHP beginner. I want my script to display members list from a table in my db and attach a hyperlink to it so that when a user clicks on the link, it takes him to the full details of that member. So far, I have been able to retrieve data from db and attached links but when I click on the link,it just adds a member ID to the query string and it does not take u to page with full member details. What I have wirtten so far is shown below:

<?php
    //connection.php
      
    $conn = mysql_connect($host, $user, $pass);
    $selDB = mysql_select_db($db);
    $sql = "select count(*) from info";
    $result = mysql_query($sql);
    $row = mysql_fetch_row($result);
    $numRows = $row[0];
    
    $sql = "select * from info";
    $result = mysql_query($sql);
    while($row = mysql_fetch_assoc($result)){ ?>
     <table>
     <td><?php echo stripslashes($row['name']). " ";?><a href="<?php echo $_SERVER['PHP_SELF']?>?id=<?php echo $row['id'];?>">[View Details]</a>
      </td>
      </tr>            
          
<?php } ?>

Guys please help me out.

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by rajarajan07
0

Why are you echoing "<table>" in the loop this will produce a very strange HTML. Put it outside the loop.

0
if (mysql_num_rows($result) > 0) { 
    // yes 
    // print them one after another 
    echo "<table cellpadding=10 border=1>"; 
    while($row = mysql_fetch_row($result)) { 
        echo "<tr>"; 
        echo "<td>".$row[0]."</td>"; 
        echo "<td>" . $row[1]."</td>"; 
        echo "<td>".$row[2]."</td>"; 
        echo "</tr>"; 
    } 
    echo "</table>"; 
} 
else { 
    // no 
    // print status message 
    echo "No rows found!"; 
}

Table things should be used like the above code

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.