1

I have the following code for displaying results in a table. I am in need of a bit of help taking the ID from Tickets table and using it on the end of the hyperlink e.g. ".php?id=7" I have been reading tutorials on this however things dont seem to be happening for me. Thanks in advance.

<table class="table">
    <tbody><tr><th>ID</th><th>Site Name</th><th>Title</th><th>Description</th><th>Quick Description</th><th>Contact</th><th>Status</th></tr>
<?php
$con = mysqli_connect(*credentials*);
if (!$con)
  {
  die('Could not connect: ' . mysqli_error());
  }

$result = mysqli_query($con, "SELECT * FROM Tickets WHERE Status='Open' AND Active='active'");

while($row = mysqli_fetch_array($result))
  {
  echo "<tr>";
  echo "<td><a href='//PHP/displayticket.php?id=$ID'>" . $row['ID'] . "</a></td>";
  echo "<td>" . $row['SiteName'] . "</td>";
  echo "<td>" . $row['Title'] . "</td>";
  echo "<td>" . $row['Description'] . "</td>";
  echo "<td>" . $row['quickdesc'] . "</td>";
  echo "<td>" . $row['Contact'] . "</td>";
  echo "<td>" . $row['Status'] . "</td>";
  echo "</tr>";
  }
echo "</table>";

mysqli_close($con);
?>  
4
  • 2
    Please, remove your password from here and change it on the server! Commented Mar 31, 2014 at 13:10
  • I edited your post to remove credentials, but it could be safer to change it anyway on your server... Commented Mar 31, 2014 at 13:12
  • Agreed with blue. Change your login password asap! Commented Mar 31, 2014 at 13:13
  • palm slaps face ah... what a stupid mistake... thanks for editing it out! Commented Mar 31, 2014 at 13:15

2 Answers 2

2
echo "<td><a href='//PHP/displayticket.php?id={$row['ID']}'>" . $row['ID'] . "</a></td>";

Do you mean like this? Or am I not understanding your question?

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

Comments

1

Replace:

while($row = mysqli_fetch_array($result))

With:

$rows = mysqli_fetch_array($result, MYSQLI_ASSOC);
foreach ( $rows AS $row )

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.