Hey guys!!!
Am building a system that user will be searching data from database..I want to display those data in table where a whole row will be a link to a specific data.For example a table will list some members of a community and each row is a link to a member profile.
Can anyone help me on how to professionally do it?
i will be so grateful

<?php ?
// start a html table
echo "<table>";

// suppose you have your query result stored in $result  
while($row = mysqli_fetch_assoc($result)) {

    // suppose this is your user from the database
    $fullName = $row['fullName'];

    // suppose this is user ID that helps constructing a link to where profiles are stored
    $userId = $row['userId'];

    // create link for that row (whatever it is, I'll just make it up)
    $link = "memberProfiles.php?userId=$userId"

    // echo one row
    echo "<tr><td><a href=\"$link\">$fullName</a></td></tr>";
}

// end a html table
echo "</table>";
>

This is just a simple example. It could be improved.

<?php ?
// start a html table
echo "<table>";

// suppose you have your query result stored in $result  
while($row = mysqli_fetch_assoc($result)) {

    // suppose this is your user from the database
    $fullName = $row['fullName'];

    // suppose this is user ID that helps constructing a link to where profiles are stored
    $userId = $row['userId'];

    // create link for that row (whatever it is, I'll just make it up)
    $link = "memberProfiles.php?userId=$userId"

    // echo one row
    echo "<tr><td><a href=\"$link\">$fullName</a></td></tr>";
}

// end a html table
echo "</table>";
>

This is just a simple example. It could be improved.

thanx...but that can only display a single member..I was thinking about something dynamic that will display even all members from database.
Here is what i have done so far

$sql2=mysql_query("SELECT * FROM dealers_details WHERE dealers_name LIKE '%".$dealer_name."%'") or die(mysql_error());
if(mysql_num_rows($sql2)!=0){
$dealerList="<table width='100%'>";
while($row=mysql_fetch_array($sql2)){
extract($row);
$dealer=base64_encode($dealer_email);

$dealerList.="<tr bgcolor='#f7f7f7'><td height='50px'><a href='dealers_profile.php?id=".$dealer."' style='background-color:#3222;' >".$dealers_name."</a></td><td><a href='mailto:".$dealer_email."'style='align:right;'>".$dealer_email."</font></a></td><td><a href='http://www.".$dealer_website."'>".$dealer_website."</a></td></tr>";
}
$dealerList.="</table>";

now what i want is for the whole row to be a link to dealers_profile.php and not each cell to hav its own link,or not the data inside the cell to be a link..but the whole row..Also how to do pagination for the results.
thanx

If I understand correctly you want to have a row clickable. I haven't tested this but I think you could use onclick event for a tr tag and a javascript to open a profile (in a same window or in a new window). Try something like:

$dealerList.="
  <tr bgcolor='#f7f7f7' onclick=\"document.location.href='memberProfiles.php?userId=$userId'\">
  <td height='50px'>...

Pagination is another topic. I use Pear Pager class for that. You can have a look at documentation, examples and code at http://pear.php.net/package/Pager. I found it very powerful and flexible and decided that it is not worth developing my own.

Be a part of the DaniWeb community

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