By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,962 Members | 1,776 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,962 IT Pros & Developers. It's quick & easy.

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

P: 6
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
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. onclick="updateDIV('viewcontact.php?UID=<?php echo $user['contactID'];?>&format=detail~user<?php echo $user['contactID'];?>content');">
  3. ?>
Apr 13 '12 #1
Share this Question
Share on Google+
2 Replies


100+
P: 1,059
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?
Apr 14 '12 #2

P: 6
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($_REQUEST['format'])
{
case "detail":
?>
<tr>
<td valign="top" rowspan=2><img src="images/triangle_redS.gif" onclick="updateDIV('viewcontact.php?UID=<?php echo $user['contactID'];?>&format=short~user<?php echo $user['contactID'];?>content');"><!-- <b>#<?php echo $usernum;?></b>--></td>
<td valign="top"><img 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><span style='color: #990000;'>BAD: "; }
echo formatPhone($user['phone1'])." - ".$user['phone1type'];
if ($user['phone1BadYN']==1) { echo "</span></i></b>"; }
?>&nbsp;<br>

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

</td>
<td valign="top" colspan=2 align="left"><img src="images/spacer.gif" width=400 height=1><br><b><?php echo date("m/d/y h:i", strtotime($user['webUserAddedOn'])).strtolower(substr(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($mySQL);
while ($userlogin = mysql_fetch_array($userlogins)) {
$mySQL = "SELECT Count(*) AS LoginCount FROM site_logins WHERE SiteID = '".$userlogin['SiteID']."' AND UserID = '".$_REQUEST['UID']."'";
$logincount = mysql_query($mySQL);
$count = mysql_fetch_array($logincount);
echo date("m/d/y h:i", strtotime($userlogin['Visit_DT'])).strtolower(substr(date("A", strtotime($userlogin['Visit_DT'])),0,1))." (".$userlogin['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="updateDIV('editcontact.php?UID=<?php echo $user['contactID'];?>~user<?php echo $user['contactID'];?>content');return false;" style="color: #000000; font-size: 8pt; font-weight: bold; text-decoration: none;"><img src="images/user_write_32.gif" width=32 height=32 border=0><br>EDIT</a><br />
<img src="images/spacer.gif" width=60 height=1><br><a href="printdetails.php?UID=<?php 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(confirm('Do you really want to delete this user?'))
{
updateDIV('deletecontact.php?UID=<?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.gif" width=32 height=32 border=0><br>DELETE</a>

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

?>
Apr 17 '12 #3

Post your reply

Sign in to post your reply or Sign up for a free account.