Jump to content

php <a href> link using mysql ID


dmcdaniel

Recommended Posts

Im fairly new to PHP and have a quick question.

 

I am creating a mail system from scratch and I have two main SQL rows, ID and read. I need to put a link around the ID so that it only pops up in a pop up window that message.

 

This is the coding I have so far, feel free to point out where I have gone wrong:

<?

include('../config/config.php');

$Query = sprintf("SELECT * FROM qa LEFT JOIN EmployeeInfo ON(qa.Agentsname = EmployeeInfo.Name) WHERE EmployeeInfo.Name LIKE '%s'", mysql_real_escape_string($_SESSION['SESS_NAME']));
$result = mysql_query($Query);
$num_rows = mysql_num_rows($result);

echo "<table border='0' cellspacing='10' cellpadding='10'>";
  echo "<tr>";
  echo "<td><strong>Message ID</strong></td><td><strong>Team Lead</strong></td><td><strong>Unread/Read</strong></td><td><strong>Score</strong></td>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr><td><a href='http://10.0.11.5/form/employees/attendance/qaview.php?id='". $row['ID'] . ">" . $row['ID'] . "</a></td><td>" . $row['Name'] . "</td><td>" . $row['read'] . "</td><td>" . $row['Score'] . "</td></tr>"; 
  }
echo "</table>";

?>

 

and this is the qaview.php page

<?

include('../config/config.php');

    $query = doquery("SELECT * FROM qa WHERE ID='$ID'");
$update_query=doquery("UPDATE qa SET read='1' WHERE ID='$ID'");
    $row = mysql_fetch_array($query);

  echo "<td><strong>" . $row['Name'] . "</strong></td></tr>";

?>

 

 

Link to comment
Share on other sites

I may have misunderstood this completely, but I think you want a pop up window which is a client side feature. PHP is all done on the server and generates the html for you, before it is rendered and displayed by the browser. I suspect that you will have to organise some kind of ajax call to generate the pop up of the information when they click on the link.

Link to comment
Share on other sites

I will only say one thing; full tags for php, the use of short tags (between servers) can stop a script in it's tracks if it's not set in the ini file.  Always use full tags, good practise & saves headaches later on.

 

Cheers,

Rw

 

 

Link to comment
Share on other sites

Maybe I didn't clarify properly. Sorry about that.

 

What I want to do is this:

 

Basically, create an internal mailer of sorts. I have a form that places info into a database and places a 0 in the read box (this signifies unread). My first page shows all of the unread messages. Where the message_id is located, I want to create a link to another page so that it ONLY brings up that one message from the database.

 

Is this possible to do in php and mysql?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.