hyperlink issue [resolved]

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
Twilight
Posts: 58
Joined: Sat Mar 17, 2012 11:11 am

hyperlink issue [resolved]

Post by Twilight »

Hi All

I have php code that is listing data in a table

I have set the id number to be a hyperlink as I want to beable to click on the link and have another windows pop up with more information.

Does anyone know how i can do this.

Code listed below for table details

Regards
Andy

Code: Select all

<H2><center>Open Tickets</center></H2>
<?php

$Ticket = $isFirst3 ['Account'];
$isTicket="SELECT * from ticket where Account='$Ticket' LIMIT 0, 10 ";
$isTicket2=mysql_query($isTicket) or die ("could not query Ticket table");


$i = 0;


  echo "<small>";

         print "<left>";
         print "<table border='0' widith='80%' cellspacing='0'>";
         print "<tr><td widith='25%' valign='top'>";
         print "</td>";
         print "<td valign='top' width='center'>";
         print "<table border='1' bordercolor='black' bgcolour='#ffffff'>";
         print "<tr><td><center>Ticket<br>Number</center><font color='ffffff'></font></td>
         <td>Service Tag<font color='ffffff'></font></td>
         <td>Ticket Title<font color='ffffff'></font></td>
         <td>Ticket Description<font color='ffffff'></font></td>
         <td>Date Opened<font color='ffffff'></font></td>
         <td>Date Closed<font color='ffffff'></font></td></tr>";




  while ($isTicket3 = mysql_fetch_array( $isTicket2 )){



   echo "<tr><td><center><A href='Ticket.php'>$isTicket3[Ticket]</a></center></td>
   <td>$isTicket3[Tag]</td>
   <td>$isTicket3[Title]</td>
   <td>$isTicket3[Description]</td>
   <td>$isTicket3[Open]</td>
   <td>$isTicket3[Close]</td></tr>";

    $i ++;

  }



print "</table>";
print "<br><A href='New_Ticket.php'>New Ticket</a><br>";
print "</td>";
print "</tr>";
print "</table>";
print "</left>";

echo "</small>";







?>
</div>
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: hyperlink issue

Post by hallsofvallhalla »

Not sure I understand what exactly you want but

Code: Select all

 echo "<tr><td><center><A href='Ticket.php'>$isTicket3[Ticket]</a>$isTicket3['Ticket']</center></td>
Should do the trick.
Twilight
Posts: 58
Joined: Sat Mar 17, 2012 11:11 am

Re: hyperlink issue

Post by Twilight »

Hi hallsofvallhalla

Thanks for your reply

I get the following error message when I enter that changed code.

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\wamp\www\Sigma\search_client.php on line 88

What i am trying to do is the following

I have a unique number called ticket number. I have set this as a hyperlink because I want to be able to click on this link to bring up the details in the database.

To do this I have set the hyper link to open another PHP file called ticket.php.

The problem I have is that I can't get ticket.php to open the required row in the database that is associated to the ticket number.

So if I click on ticket number 22, I want it to open a new window with all the details that are0associated to ticket 22.

I hope I have made it clearer if not please just say and I will try and explain in a different way.

Again. Thanks for all your help so far

Regards
Andy
Winawer
Posts: 180
Joined: Wed Aug 17, 2011 5:53 am

Re: hyperlink issue

Post by Winawer »

Maybe something like:

Code: Select all

<a href="Ticket.php?ticket=<?php echo $isTicket3['Ticket'] ?>" onclick="window.open(this.href, 'Ticket Details', 'left=20,top=20,width=500,height=500,toolbar=0,location=0,menubar=0'); return false;"><?php echo $isTicket3['Ticket'] ?></a>
And in ticket.php:

Code: Select all

$ticket = (int)$_GET['ticket'];
$query = "SELECT * FROM ticketdetails WHERE ticket = " . $ticket;
//etc.    
Twilight
Posts: 58
Joined: Sat Mar 17, 2012 11:11 am

Re: hyperlink issue

Post by Twilight »

Hi

Thanks for your replies. I am still not getting this thing to work.

I have listed both sets of code below.

search_client.php

Code: Select all

<?php
include 'connect.php';
include_once 'logo.php';
include_once 'logo2.php';
session_start();
?>
<link href="layout.css" rel="stylesheet" type="text/css" />
<div id="Title" div align="left">

<?php
$Account=$_POST['Account'];
$Client=$_POST['Client'];
$Company=$_POST['Company'];
$Phone=$_POST['Telephone'];
$Post=$_POST['Post'];

$Account=strip_tags($Account);
$Client=strip_tags($Client);
$Company=strip_tags($Company);
$Phone=strip_tags($Phone);
$Post=strip_tags($Post);


if (($Account == "") && ($Client =="") && ($Company =="") && ($Phone =="") && ($Post ==""))
{
echo "You have not entered a vaild search request!";
echo " <A href='search.php'>Go back</a><br>";
exit;
}
$isFirst1="SELECT * from clients where Account='$Account' || Client='$Client' || Company='$Company' || Phone='$Phone' || Postcode='$Post' ";
$isFirst2=mysql_query($isFirst1) or die ("could not query players table1");
$isFirst3=mysql_fetch_array($isFirst2);




if(($isFirst3))

{
echo "<H2>Client Details</H2>";
echo "Account Name:" . $isFirst3 ['Account'];
echo "<br>Client Name:" . $isFirst3 ['Client'];
echo "<br>Company Name:" . $isFirst3 ['Company'];
echo "<br><A href='search.php'>Go back</a><br>";

}

?>
</div>

[size=150][b]// only intrested in this section[/b][/size]

<link href="layout.css" rel="stylesheet" type="text/css" />
<div id="client" div align="left">

<H2><center>Open Tickets</center></H2>
<form id="Ticketnum" action="ticket.php" method="post">

<?php

$Ticket = $isFirst3 ['Account'];
$isTicket="SELECT * from ticket where Account='$Ticket' LIMIT 0, 10 ";
$isTicket2=mysql_query($isTicket) or die ("could not query Ticket table");


$i = 0;


  echo "<small>";

         print "<left>";
         print "<table border='0' widith='80%' cellspacing='0'>";
         print "<tr><td widith='25%' valign='top'>";
         print "</td>";
         print "<td valign='top' width='center'>";
         print "<table border='1' bordercolor='black' bgcolour='#ffffff'>";
         print "<tr><td><center>Ticket<br>Number</center><font color='ffffff'></font></td>
         <td>Service Tag<font color='ffffff'></font></td>
         <td>Ticket Title<font color='ffffff'></font></td>
         <td>Ticket Description<font color='ffffff'></font></td>
         <td>Date Opened<font color='ffffff'></font></td>
         <td>Date Closed<font color='ffffff'></font></td></tr>";




  while ($isTicket3 = mysql_fetch_array( $isTicket2 )){

   
   echo "<tr><td><center><A href=Ticket.php onclick =$isTicket3[Ticket]('Ticketnum') >$isTicket3[Ticket]</a></center></td>
   <td>$isTicket3[Tag]</td>
   <td>$isTicket3[Title]</td>
   <td>$isTicket3[Description]</td>
   <td>$isTicket3[Open]</td>
   <td>$isTicket3[Close]</td></tr>";

    $i ++;

  }


print "</table>";
print "<br><A href='New_Ticket.php'>New Ticket</a><br>";
print "</td>";
print "</tr>";
print "</table>";
print "</left>";

echo "</small>";


?>

</div>

</form>



[b][size=150]// Ticket.php[/size][/b]

<?php
include 'connect.php';
include_once 'logo.php';
include_once 'logo2.php';
session_start();
?>

<link href="layout.css" rel="stylesheet" type="text/css" />
<div id="Ticket1" div align="left">

<?php


$Ticket= $_Post['Ticketnum'];

$isFirst1="SELECT * from Ticket where ticket = '$Ticket'";
$isFirst2=mysql_query($isFirst1) or die ("could not query players table1");



  echo "<small>";

         print "<center>";
         print "<table border='0' widith='70%' cellspacing='20>";
         print "<tr><td widith='25%' valign='top'>";
         print "</td>";
         print "<td valign='top' width='75%'>";
         print "<table border='1' bordercolor='black' bgcolour='#ffffff'>";
         print "<tr><td>Name<font color='ffffff'></font></td>
         <td>Ticket ID<font color='ffffff'></font></td>
         <td>Title<font color='ffffff'></font></td>
         <td>Description<font color='ffffff'></font>
         <td>Summary<font color='ffffff'></font></td></tr>";

print "</table>";
print "</td>";
print "</tr>";
print "</table>";
print "</center>";
      echo "</small>";

echo "<br><A href='Ticket_search.php'>Go back</a><br>";
?>
Open Tickets

Ticket
Number
Service Tag Ticket Title Ticket Description Date Opened Date Closed
22 123456 test this is a test 2012-05-02 10:00:00 0000-00-00 00:00:00
23 123456 test this is a test 2012-05-02 10:00:00 0000-00-00 00:00:00
New Ticket

Thanks again
Regards
Andy
Last edited by Twilight on Mon May 21, 2012 11:08 am, edited 2 times in total.
User avatar
Foofighter
Posts: 121
Joined: Sun Mar 04, 2012 1:52 pm

Re: hyperlink issue

Post by Foofighter »

@offtic pls start using Tags for better readability.. additionally u can add eg.

Code: Select all

 for syntax highlighting.
Twilight
Posts: 58
Joined: Sat Mar 17, 2012 11:11 am

Re: hyperlink issue

Post by Twilight »

Sorry

I did not know you could do this. I have now edited my last reply

Regards
Andy
Winawer
Posts: 180
Joined: Wed Aug 17, 2011 5:53 am

Re: hyperlink issue

Post by Winawer »

Code: Select all

echo "<tr><td><center><A href=Ticket.php onclick =$isTicket3[Ticket]('Ticketnum') >$isTicket3[Ticket]</a></center></td>
   <td>$isTicket3[Tag]</td>
   <td>$isTicket3[Title]</td>
   <td>$isTicket3[Description]</td>
   <td>$isTicket3[Open]</td>
   <td>$isTicket3[Close]</td></tr>"; 
Makes no sense. Try

Code: Select all

echo "<tr><td><center><A href=\"Ticket.php?Ticketnum=$isTicket3[Ticket]\" onclick=\"window.open(this.href, 'Ticket Details', 'left=20,top=20,width=500,height=500,toolbar=0,location=0,menubar=0'); return false;\" >$isTicket3[Ticket]</a></center></td>
   <td>$isTicket3[Tag]</td>
   <td>$isTicket3[Title]</td>
   <td>$isTicket3[Description]</td>
   <td>$isTicket3[Open]</td>
   <td>$isTicket3[Close]</td></tr>";
 
And in Ticket.php:

Code: Select all

$Ticket= (int)$_GET['Ticketnum']; //assuming ticket is an integer, otherwise use mysql_real_escape_string

$isFirst1="SELECT * from Ticket where ticket = $Ticket";

//etc.
 
Twilight
Posts: 58
Joined: Sat Mar 17, 2012 11:11 am

Re: hyperlink issue

Post by Twilight »

Hi All

Thanks for your help on this one. I have resolved this issue but was not able to update the post as i had lost my login details.

Regards
Andy
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: hyperlink issue [resolved]

Post by Jackolantern »

Glad to see it got resolved! Changed to [resolved] in title :)
The indelible lord of tl;dr
Post Reply

Return to “Beginner Help and Support”