I have to click a search button twice in order to get the results when the file loads

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Pamr
    New Member
    • Dec 2011
    • 6

    I have to click a search button twice in order to get the results when the file loads

    My site is programmed with php and javascript. I have a search button which it searches records from my database. I have two different programming codes into the same file which retrieve data, the first one retrieves emails in the text area and the other retrieves names and other details. The one which retrieves emails work fine but the other doesn’t retrieve data until I click search button twice when the file first loads. After clicking the search button twice at the first time, the problem disappears and it works fine for the rest of the searches. The one which retrieves email is programmed with pure php but the other actually uses javascript (updateDIV()) and pull other php file. It gets the userid first and then uses that userid to fetch other records. Below is the sample code
    Code:
    <?php
    onclick="updateDIV('viewcontact.php?UID=<?php echo $user['contactID'];?>&format=detail~user<?php echo $user['contactID'];?>content');">
    ?>
    Last edited by Dormilich; Apr 16 '12, 05:50 AM. Reason: Please use [CODE] [/CODE] tags when posting code.
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    is this your actual code?

    any way the url you are sending is something like below

    viewcontact.php ?UID=contactID&format=detail~ usercontactID']content

    my question is was this suppose to be like this?

    Comment

    • Pamr
      New Member
      • Dec 2011
      • 6

      #3
      viewcontact.php is the php file which displays the name and other details in my database. There is a case statement in viewcontact.php file which displays the info when format is equal to details.. see below the codes of viewcontact.php file: I think it will help you to understand the meaning of that string of code.
      <?php
      switch($_REQUES T['format'])
      {
      case "detail":
      ?>
      <tr>
      <td valign="top" rowspan=2><img src="images/triangle_redS.g if" onclick="update DIV('viewcontac t.php?UID=<?php echo $user['contactID'];?>&format=shor t~user<?php echo $user['contactID'];?>content');"> <!-- <b>#<?php echo $usernum;?></b>--></td>
      <td valign="top"><i mg src="images/spacer.gif" width=250 height=1><br><b ><?php echo $user['namefirst']." ".$user['namelast'];?></b>&nbsp;<br>
      <?php echo $user['address1'];?>&nbsp;<br>
      <?php echo $user['city'].", ".$user['state'];?>&nbsp;&nbsp; <?php echo $user['zip'];?>&nbsp;<br>
      <a href="mailto:<? php echo $user['email1'];?>"><?php echo $user['email1'];?></a>&nbsp;<br>
      <?php
      if ($user['phone1BadYN']==1) { echo "<b><i><spa n style='color: #990000;'>BAD: "; }
      echo formatPhone($us er['phone1'])." - ".$user['phone1type'];
      if ($user['phone1BadYN']==1) { echo "</span></i></b>"; }
      ?>&nbsp;<br>

      <?php if (!($_SESSION["email1"] == "sean@westcoast mortgage.biz")) { echo "Password: ".$user['webUserPasswor d']."&nbsp;<br />";}?>
      Referred by: <?php echo ucwords($user['findus']);?>&nbsp;<br />
      Signed Buyer Agreement? <?php echo $user['webUserAgreeme nt'];?>&nbsp;<br />

      </td>
      <td valign="top" colspan=2 align="left"><i mg src="images/spacer.gif" width=400 height=1><br><b ><?php echo date("m/d/y h:i", strtotime($user['webUserAddedOn '])).strtolower(s ubstr(date("A", strtotime($user['webUserAddedOn '])),0,1))." (".$user['webUserRegSite ']." - Registered On)";?></b>
      <div style="height: 100px; overflow:auto; border-top: 1px solid #ddd;">
      <?php
      $mySQL = "SELECT SiteID, Visit_DT from site_logins WHERE UserID = '".$_REQUEST['UID']."' ORDER BY Visit_DT DESC";
      $userlogins = mysql_query($my SQL);
      while ($userlogin = mysql_fetch_arr ay($userlogins) ) {
      $mySQL = "SELECT Count(*) AS LoginCount FROM site_logins WHERE SiteID = '".$userlogi n['SiteID']."' AND UserID = '".$_REQUEST['UID']."'";
      $logincount = mysql_query($my SQL);
      $count = mysql_fetch_arr ay($logincount) ;
      echo date("m/d/y h:i", strtotime($user login['Visit_DT'])).strtolower(s ubstr(date("A", strtotime($user login['Visit_DT'])),0,1))." (".$userlogi n['SiteID']." Login - ".$count['LoginCount']." Total)<br />";
      }
      ?></div>
      </td>
      <td valign="top" align="center"> <img src="images/spacer.gif" width=60 height=1><br><a href="#" onclick="update DIV('editcontac t.php?UID=<?php echo $user['contactID'];?>~user<?php echo $user['contactID'];?>content');re turn false;" style="color: #000000; font-size: 8pt; font-weight: bold; text-decoration: none;"><img src="images/user_write_32.g if" width=32 height=32 border=0><br>ED IT</a><br />
      <img src="images/spacer.gif" width=60 height=1><br><a href="printdeta ils.php?UID=<?p hp echo $user['contactID'];?>" target="_blank" style="color: #000000; font-size: 8pt; font-weight: bold; text-decoration: none;"><img src="images/print_24.gif" border=0><br> PRINT</a>

      <img src="images/spacer.gif" width=60 height=1><br><a href="#" onclick="if(con firm('Do you really want to delete this user?'))
      {
      updateDIV('dele tecontact.php?U ID=<?php echo $user['contactID'];?>~user<?php echo $user['contactID'];?>content');
      }
      else{
      return false;
      } " style="color: #000000; font-size: 8pt; font-weight: bold; text-decoration: none;"><img src="images/user_close_32.g if" width=32 height=32 border=0><br>DE LETE</a>

      </td></tr>
      <tr>
      <td colspan=10 style='border-bottom: solid 1px #cccccc;'><b>NO TES:</b> <?php echo $user['notes'];?><div style="line-height: 1px; font-size: 1px;">&nbsp;</div></td>
      </tr>
      </table>
      <?php
      break;

      ?>

      Comment

      Working...