Hi,

I'm retrieving data from a database where it is being called onto a page based on what is in the database. What i want to do is organise this data into a sortable table whereby the user will be able to click on the column header and sort by ascending or descending. The user should be able to click on each row which will bring them to another page and call the data from that particular row. (please see www.tenderme.ie as an example - the homepage has a table that is being called from the database and the user can click on whatever row they wish which will bring them to another page. ) This table isn't sortable but if i got the data in the form of a table i would be happy. As you can see from the attached screenshot, the data is being called into a teble but only the first row is clickable. I think the problem here is that the php code only echoes one <tr> row. I would appreciate if anyone could assist with this. Does anyone know any possible way of organising this into a table (sortable if possible) where the user can hover over each row and click whatever row they want. Thank you. Here is the code which is calling the data from the database...

<?php 
            $con = mysql_connect("xxx","xxx","xxx"); 
            if (!$con) 
              { 
              die('Could not connect: ' . mysql_error()); 
              } 

            mysql_select_db("xxx", $con); 

            $result = mysql_query("SELECT * FROM proposal WHERE username = '$username'"); 

            echo "<table cellpadding='0'> 
            <thead> 
                <th>Location</th> 
                <th>Hotel Star</th> 
                <th>Check-in</th> 
                <th>Check-out</th> 
            </thead>"; 

            while($row = mysql_fetch_array($result)) 
              { 
                echo "<tr>"; 
                  echo "<td>" . $row['county'] . "</td>"; 
                  echo "<td>" . $row['starrating'] . "</td>"; 
                  echo "<td>" . $row['checkin'] . "</td>"; 
                  echo "<td>" . $row['checkout'] . "</td>"; 
                echo "</tr>"; 
              } 
            echo "</table>"; 

            mysql_close($con); 
            ?>

what your going to want to do is make a forum for that table and when they click on the header name have it post to it self and then use those vars to sort it in the query

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.