0

I am displaying some fields from mysql database using php as given in screen shots. Actually each person has lots of data in several tables. The screen shot displaying only few collected from several tables. Now to display all information corresponding to a person it will be easy if the field usn (say 10IS037) is a link such that whenever i click on any usn then it redirects to another page where the whole information will be display using some query. Now i am trying but i can not make any link of us filed. please see the screen shot. enter image description here

A portion of Code is here..

<?php
            include('includes/login_connection.php');

        //  $query = "select * from personal_details, course_codes";
            $query = "select p.usn, p.name, p.sem, p.year, cg.cur_cgpa, c.cc1, c.cc2, c.cc3, c.cc4, c.cc5, c.cc6, c.cc7, c.cc8, c.cc9 from personal_details p, course_codes c, cgpa_details cg where p.usn = c.usn AND p.usn = cg.usn order by p.usn";

            $run = mysql_query($query) or die($query."<br/><br/>".mysql_error()); 
            $num=mysql_numrows($run);
            echo "No. of registered students: $num";
            while($row = mysql_fetch_assoc($run)){


                echo "<tr>";
                echo "<td>" . $row['usn'] . " </td>";
                echo "<td>" . $row['name'] . " </td>";
                echo "<td>" . $row['sem'] . " </td>";
                echo "<td>" . $row['year'] . " </td>";
                echo "<td>" . $row['cur_cgpa'] . " </td>";
                echo "<td>" . $row['cc1'] . " </td>";
                echo "<td>" . $row['cc2'] . " </td>";
                echo "<td>" . $row['cc3'] . " </td>";
                echo "<td>" . $row['cc4'] . " </td>";
                echo "<td>" . $row['cc5'] . " </td>";
                echo "<td>" . $row['cc6'] . " </td>";
                echo "<td>" . $row['cc7'] . " </td>";
                echo "<td>" . $row['cc8'] . " </td>";
                echo "<td>" . $row['cc9'] . " </td>";
                echo "</tr>";

    //      echo "</table>";    


            }
            mysql_close($bd);

?>

And html part is given in pics.. sorry i can not paste text

![enter image description here][2]

<table border='1' align="center" style="font-size:14px" width="95%" cellspacing="3" class="db_table" >

<tr class="db_table_tr" >
 <th class="db_table_th" >USN</th>
 <th class="db_table_th" >Name</th>
 <th class="db_table_th" >Sem</th>
 <th class="db_table_th" >Year</th>
 <th class="db_table_th" >CGPA</th>
 <th class="db_table_th" >Subject-1</th>
 <th class="db_table_th" >Subject-2</th>
 <th class="db_table_th" >Subject-3</th>
 <th class="db_table_th" >Subject-4</th>
 <th class="db_table_th" >Subject-5</th>
 <th class="db_table_th" >Subject-6</th>
 <th class="db_table_th" >Subject-7</th>
 <th class="db_table_th" >Subject-8</th>
 <th class="db_table_th" >Subject-9</th>
</tr></table>
4
  • 2
    You need to clarify your question and provide your code. Commented Jul 30, 2013 at 17:39
  • 99 times out of 100 the screenshot attached to a question is either totally useless, or would be better presented as text. Code and your database schema speak volumes. This screenshot is confusing, though points for not having any embarrassing tabs open. Commented Jul 30, 2013 at 17:46
  • but i can not upload.. shows error due to <tr> tag Commented Jul 30, 2013 at 17:56
  • Are you trying to create a link to redirect to a different page for each USN? Commented Jul 30, 2013 at 18:46

2 Answers 2

1

The echo's are generally not considered good PHP coding practice and your PHP code is not correctly drawing the table (It's missing the table header). However, having said that, using your coding style.

Change the line

echo "<td>" . $row['usn'] . " </td>";

to

echo "<td> <a href='http://somedomain/somepath/usn_handler.php?usn='" . $row['usn'] .
     "' >" . $row['usn'] . "<a/> </td>";

Please note I am not correcting your code, as there is a lot I can see wrong. Please do so yourself.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks a lot. can you please answer stackoverflow.com/questions/17957104/…
1
<?php
 $link = $row['usn'];
?>
<td><a href="filename.php?usn=<?php echo $link; ?>"><?php echo $link; ?></a></td>

But am concerned you can write PHP without knowing basic HTML

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.