Another php issue-SOLVED

14 replies
I need to echo a php var into this form... I cant get it to work. This is my code:

KEEP IN MIND I HAVE TAKEN OUT THE INSTANCES OF . AND H,T,T,P,:,//
BECAUSE I CANT POST LINKS YET...

$oh = "id='$i'";
$on = "name='$i'";
$toosl = "<a href='mynewcityDOTcom/distribute/osticket_1.6.0/upload/scp/ticketsDOTphp?id=$ticketID'>'$ticketID'</a>";
$off = "'$toosl'";
$selstatus = "<form method='post' '$oh' '$on' action='mynewcityDOTcom/getleadsDOTphp'><tr><td><input type='text' name='ticketID' value='$off'></td><td><input type='text' value='$created'></td><td><select name='status'><option value='Renter Keep'>Renter Keep<option value='Renter Reject'>Renter Reject<option value='SPAM'>SPAM<option value='Sold Buyer'>Sold Buyer<option value='Sold Seller'>Sold Seller<option value='Not Moving'>Not Moving<option value='Listed Home'>Listed Home</select></td><td><input type='text' value='$subject' size='75'></td><td><input type='text' value='$lo_franchise'></td><td><input type='text' value='$lo_email'></td><td><input type='text' value='$lo_name'></td><td><input type='text' value='$lead_email'></td><td><input type='text' value='$lead_name'></td><td><input type='submit' name='doit' value='submit'></form></td></tr>";



When I view source that table row echos out like this in the source:


<form method='post' 'id='0'' 'name='0'' action='mynewcityDOTcom/getleadsDOTphp'><tr><td><input type='text' name='ticketID' value=''<a href='mynewcityDOTcom/distribute/osticket_1.6.0/upload/scp/ticketsDOTphp?id='>''</a>''></td><td><input type='text' value=''></td><td><select name='status'><option value='Renter Keep'>Renter Keep<option value='Renter Reject'>Renter Reject<option value='SPAM'>SPAM<option value='Sold Buyer'>Sold Buyer<option value='Sold Seller'>Sold Seller<option value='Not Moving'>Not Moving<option value='Listed Home'>Listed Home</select></td><td><input type='text' value='' size='75'></td><td><input type='text' value=''></td><td><input type='text' value=''></td><td><input type='text' value=''></td><td><input type='text' value=''></td><td><input type='text' value=''></td><td><input type='submit' name='doit' value='submit'></form></td></tr>

on the input with the name ticketID the href is supposed to give the ticketID as the id in the url it points to. then in the actual table the user sees it needs to show the ticketID as a clickable link.. Make sense?
#insanity #issue #php
  • Profile picture of the author KirkMcD
    Where are you setting ticketID and the other variables in the form? Are you sure that part is working?
    {{ DiscussionBoard.errors[5890781].message }}
  • Profile picture of the author PHPSpaZ
    The selstatus var is used later in a while loop, the rest of the form displays fine, the only problem I believe is with my syntax in the input box where I want to make the value = to a link while also still displaying the ticketID as the links clickable text.
    {{ DiscussionBoard.errors[5890859].message }}
    • Profile picture of the author KirkMcD
      Originally Posted by PHPSpaZ View Post

      The selstatus var is used later in a while loop, the rest of the form displays fine, the only problem I believe is with my syntax in the input box where I want to make the value = to a link while also still displaying the ticketID as the links clickable text.
      When you set the variable it's done. It won't change later on because you changed a variable to create the original.
      selstatus needs to be set just before you use it.
      {{ DiscussionBoard.errors[5894456].message }}
  • Profile picture of the author Tradeout
    I'm going to be honest and say that is a convuluted way of coding....

    Anyway a quick way to check if the ticketId variable is set is to to try echoing it to screen then exit the code. Ie

    echo $ticketID; exit;

    Its a good way of debugging variable problems.
    {{ DiscussionBoard.errors[5892494].message }}
    • Profile picture of the author PHPSpaZ
      I agree. It is convoluted, by I am a beginner and what I'm building is huge! This is why I appreciate all the help. That said, my problem is simply with quotes... I know It can be done this way but I get confused with all the quotes. If there is an easier way to display the link in the form field I am open to suggestions Thanks again for all the help!!! Looking to retain a programmer to helping me learn proper coding. Anyone interested. I'm a quick study
      {{ DiscussionBoard.errors[5893982].message }}
  • Profile picture of the author PHPSpaZ
    I change the name of the form dynamically in the while loop via the $i var. It works in Manny each form name unique as well as displaying everything on the page in the correct way with the correct info. The only problem is for the ticketID column where it displays the ticketID perfectly UNTIL I try to turn hat ticketID into a clickable link to another page.
    {{ DiscussionBoard.errors[5895799].message }}
  • Profile picture of the author Earnie Boyd
    Working your post backword, as I understand you, you want this

    <input type='text' name='ticketID' value=''>
    to be a clickable link, is that correct? Can an input form value contain a clickable link? I think you just need to do this output the HREF in the <td>...</td> pair. Or am I missing what you are trying to do?
    Signature
    {{ DiscussionBoard.errors[5896071].message }}
    • Profile picture of the author PHPSpaZ
      Originally Posted by Earnie Boyd View Post

      Working your post backword, as I understand you, you want this



      to be a clickable link, is that correct? Can an input form value contain a clickable link? I think you just need to do this output the HREF in the <td>...</td> pair. Or am I missing what you are trying to do?
      I suppose I could do it that way... The only problem is that I still need to echo the $ticketID into the href in the table for each ticket shown. This goes to a modified version of OSTicket That I have modified to track leads. the link needs to go to tickets.php BUT it must carry the specific $ticketID with it. like so:

      <a href='http://mynewcity.com/distribute/...../tickets.php?id="$ticketID"'>$ticketID</a>
      This way the ticket number is the actual link. The problem of course is having to use another set of double quotes inside the double quotes of the $selstatus declaration... I need a work around and honestly don't really know how to do it.
      Thanks again for everyones help! Looking forward to hearing from everyone!
      {{ DiscussionBoard.errors[5896796].message }}
  • Profile picture of the author Stuart Macfarlane
    If you want to use double quotes within selstatus all you need to do is make sure you escape them first.

    For example here is an echo statement that echos out html code including double quotes:

    $test = "<a href=\"www.test.com\">www.test.com</a>";
    echo $test;

    Notice the extra \ before any html double quote
    {{ DiscussionBoard.errors[5897861].message }}
  • Profile picture of the author jawanda
    You are so close, I would do this:

    <input type='hidden' name='ticketID' value='$ticketID'>$off

    This way, you are still storing ticketID in a hidden form field, and then you are spitting out you link where that 'input' would normally be. You don't want to store the HTML in the input "value" property.
    {{ DiscussionBoard.errors[5898060].message }}
  • Profile picture of the author jawanda
    Actually, one other thing ...

    $toosl = "<a href='mynewcityDOTcom/distribute/osticket_1.6.0/upload/scp/ticketsDOTphp?id=$ticketID'>".$ticketID."</a>";

    and then replace $off with $toosl, ie:

    <input type='hidden' name='ticketID' value='$ticketID'>$toosl

    $off was just redundant and confusing.
    {{ DiscussionBoard.errors[5898075].message }}
    • Profile picture of the author PHPSpaZ
      Originally Posted by jawanda View Post

      Actually, one other thing ...

      = "<a href='mynewcityDOTcom/distribute/osticket_1.6.0/upload/scp/ticketsDOTphp?id='>".."</a>";

      and then replace with , ie:

      <input type='hidden' name='ticketID' value=''>

      was just redundant and confusing.


      I have tried this method and the other method mentioned by stuart... Clever and simple yes but they still did not function. All I get as link text is a \ or "'..'" where the .. is clickable but even though it redirects me to the correct page it does not have the $ticketID as the id= in the url vars... I can post links now so I will post the entirety of the code except for the security checks at the top which I ASSURE you have nothing to do with our problem...






      <?
      if(isset($notgonnashowuthis)){
      setcookie("notgonnashowuthis[notgonnashowuthis]", "yes", time()+900000);
      setcookie("notgonnashowuthis[notgonnashowuthis]", "notgonnashowuthis", time()+900000);
      }
      $li = $_COOKIE["notgonnashowuthis"];
      $ruhere = $li["notgonnashowuthis"];
      if ($ruhere == "notgonnashowuthis"){
      $cook = $_COOKIE['notgonnashowuthis'];
      $agentemail = $cook['notgonnashowuthis'];
      ?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <title>Untitled Document</title>
      </head>
      <?

      function ticket_connect() {
      $db_host = "notgonnashowuthis";
      $db_user = "notgonnashowuthis";
      $db_password ="notgonnashowuthis";
      $db_name = "notgonnashowuthis";
      //create database connection
      $connection = @mysql_connect($db_host,$db_user,$db_password);
      //if there is no connection then display a message letting the user know.
      if($connection) {
      @mysql_select_db($db_name, $connection);
      }
      else{
      echo "ERROR!! Could not connect to the database at this time, we are sorry for the inconvenience. Please try again later.";
      }
      } // end function db_connect()

      ?>
      <body>
      <?

      ticket_connect();
      $result = mysql_query("SELECT ticketID,created,lead_status,subject,lo_franchise, email,name,lead_email,lead_name FROM mynewci_ticket WHERE email='$agentemail'") or die(mysql_error());
      $numrows= mysql_num_rows($result);

      echo "<table id='gettickettable' border='1'>";
      echo "<th>Ticket Number</th><th>Capture Date</th><th>Status</th><th>Subject</th><th>Franchise</th><th>Lead Owner</th><th>Owner Name</th><th>Lead Email</th><th>Lead Name</th><th>Submit</th>";
      $i = 0;

      while($row = mysql_fetch_array( $result )) {

      $oh = "id='$i'";
      $on = "name='$i'";
      $selstatus = "<form method='post' '$oh' '$on' action='http://mynewcity.com/getleads.php'><tr><td><input type='hidden' name='ticketID' value='$ticketID'>'$toosl'</td><td><input type='text' value='$created'></td><td><select name='status'><option value='Renter Keep'>Renter Keep<option value='Renter Reject'>Renter Reject<option value='SPAM'>SPAM<option value='Sold Buyer'>Sold Buyer<option value='Sold Seller'>Sold Seller<option value='Not Moving'>Not Moving<option value='Listed Home'>Listed Home</select></td><td><input type='text' value='$subject' size='75'></td><td><input type='text' value='$lo_franchise'></td><td><input type='text' value='$lo_email'></td><td><input type='text' value='$lo_name'></td><td><input type='text' value='$lead_email'></td><td><input type='text' value='$lead_name'></td><td><input type='submit' name='doit' value='submit'></form></td></tr>";

      if($i <= $numrows){
      $ticketID = $row['ticket_id'];
      $created = $row['created'];
      $subject = $row['subject'];
      $lo_franchise = $row['lo_franchise'];
      $lo_email = $row['email'];
      $lo_name = $row['name'];
      $lead_email = $row['lead_email'];
      $lead_name = $row['lead_name'];
      $toosl = "<a href='http://mynewcity.com/distribute/osticket_1.6.0/upload/view.php?id=\"$ticketID\''>.$ticketID.</a>";

      // Print out the contents of each row into a table
      echo $selstatus;
      $i++;
      }
      }
      echo "</table>";
      } else {
      if(!$ruhere == "yes") {
      ?>

      <script type="text/javascript">
      window.location="http://mynewcity.com/agentlogin.php";
      </script>

      <?
      }
      }
      ?>
      </body>
      </html>


      There it is in all its........ Glory...... I hope this will help it all make sense.
      Keep in mind I have tried ALL suggestions made so far.
      {{ DiscussionBoard.errors[5900130].message }}
  • Profile picture of the author Earnie Boyd
    You are setting $selstatus with variables that have not been set so when you echo $selstatus it doesn't contain the values you expect. You need to move the setting of $selstatus to below the if($i <= $numrows){ ... } block.
    Signature
    {{ DiscussionBoard.errors[5905979].message }}
    • Profile picture of the author PHPSpaZ
      Originally Posted by Earnie Boyd View Post

      You are setting with variables that have not been set so when you echo it doesn't contain the values you expect. You need to move the setting of to below the if( <= ){ ... } block.

      I just figured it out this morning!!! Thanks to everyone for all the help! Earnie you are correct, I needed to move it below the while loop, but as well, as I was creating the $ticketID var from $row['ticket_id'] I was not actually pulling ticket_id from the db.... I was pulling ticketID which are two different rows so the $ticketID var was empty...... I also just added the href in the table row and put a hidden field with the $ticketID var in it! So simple, stupid mistake, I'm just glad for the Warrior forums and all you guys there to jar my brain. Thanks everyone!!!
      {{ DiscussionBoard.errors[5906340].message }}

Trending Topics