www.webdeveloper.com
Results 1 to 2 of 2

Thread: PHP Clickable Table

  1. #1
    Join Date
    Apr 2011
    Posts
    1

    PHP Clickable Table

    Hi I'm relatively new to PHP and am creating a recruitment website. On my vacancies page I have a table which is populated with the vacancies in the database. I want the user to be able to click a row and be taken to the Vacancy info page. Here is my current code

    PHP Code:
    <?php
    include("connection.php"); //Connect to the Recruitment database
    $conn=@mysql_connect(localhost,$user,$pass);
    $rs=@mysql_select_db("recruitment") or die( "Unable to select database");
    $sql="SELECT CompanyTitle, Title, RoleDescription, AnnualSalary, EndDate FROM vacancy ORDER BY CompanyTitle";
    $result=mysql_query($sql)or die("Insert Error: ".mysql_error());
    $num_rows mysql_num_rows($result);

    print 
    "  <table> \n";

    print 
    "    <tr> \n";
    while (
    $field mysql_fetch_field($result))
    {
    print 
    "    <th>$field->name</th> \n";
    }
    print 
    "    </tr> \n";

    while(
    $rowmysql_fetch_assoc($result))
    {
    print 
    "    <tr> \n";
    foreach (
    $row as $name => $value)
    {
    print 
    "    <td>$value</td>
     \n"
    ;
    }
    print 
    "    </tr> \n";
    }
    print 
    "    </table> \n";
    mysql_close();
    ?>
    As you see it's a plain table with no links. I'm unsure where to insert my href code linking them to the info page. Any help would be appreciated thanks!

  2. #2
    Join Date
    Jul 2007
    Location
    Wisconsin
    Posts
    468
    My guess would be here:
    PHP Code:
    print "    <td><a href=\"#\">$value</a></td> \n"
    but really, it can go anywhere that you would normally put an href in HTML.

    I don't see any sort of "location" that's being pulled from the query, so where/how you find the links to the specific info pages is still on you.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles