miz_luvly@hotmail.com Posted June 9, 2006 Share Posted June 9, 2006 HiI have a form where reps add reports. I also have a link where reps can lookup account no by entering their name and customer name. once account no is found they have to type that number in the form. Is possible to auto-select account no from lookup page and add it to the account no textbox on the form. i have added a link in account lookup page but not sure what to do next to make it work.[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Account No|Customer Name |Town | Post Code |Rep Name | Click to add xxxx | abc |xyz | xxxx xxx |aaaaa |ADD [/quote]here is the code:[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?php require 'conn.php'; if (($_GET['customer_name']!="")) { $sql = "select * from rep_table WHERE repname like '".$_GET['repname']."' and"; if ($_GET['customer_name']!="") { $sql = $sql." CUSTOMER_NAME LIKE '".$_GET['customer_name']."%'"; } $result = mysql_query($sql); if (!$result) { echo 'Could not run query: ' . mysql_error(); } echo "<table border=1 align='center' class='rep' width ='' " . "cellspacing='0'"."callpadding='5'>\n"; echo "<tr><th class='searchHeader'><caption><b> Search Results</b></caption> </th></tr>\n"; echo "<tr><td align='center'><b>Account No:</td><td><b>Customer Name:</td><td><b>Town:</td><td><b>Post Code:</td><td><b>Rep Name:</b></td><td>Click to add</td></tr>"; if ($result and !mysql_num_rows ($result)) { echo "<tr class='row1'><td colspan='4'>No results found that match the "; echo "search term(s)"; echo '</br><font color="red">please go back and try again</font></br>'; } else { while($row = mysql_fetch_array($result, MYSQL_BOTH)) { $ACCOUNT_NO=$row["ACCOUNT_NO"]; $CUSTOMER_NAME=$row["CUSTOMER_NAME"]; $ADDRESS3=$row["ADDRESS3"]; $POST_CODE=$row["POST_CODE"]; $Rep_Name=$row["Rep_Name"]; echo "<tr><td align='center'>$ACCOUNT_NO</td> <td>$CUSTOMER_NAME</td> <td>$ADDRESS3</td> <td>$POST_CODE</td> <td>$Rep_Name</td> <td><a href='repform.php?cmd=update&account_no=$ACCOUNT_NO'>ADD</a></td></tr>"; } } } echo "</table>";?> [/quote]thanks in advanceSab Quote Link to comment https://forums.phpfreaks.com/topic/11569-select-and-copy-data-by-a-click/ Share on other sites More sharing options...
wisewood Posted June 9, 2006 Share Posted June 9, 2006 <input type="text" value="<?php echo $ACCOUNT_NO ?>"> Quote Link to comment https://forums.phpfreaks.com/topic/11569-select-and-copy-data-by-a-click/#findComment-43581 Share on other sites More sharing options...
joquius Posted June 9, 2006 Share Posted June 9, 2006 Hi just some general points first.There are quite a few issues with the _GET verification. First of all you should always ?isset() _GET vars. The second if query is the same as the first so it should be emmited. Aslo "AND" should be moved to the optional sql as it will make an open query if the optional is not appended.I will not go into the code too much, but what you could can do is simply add a ?user=<?=$user?> on the redirect back to the other page, or added the user lookup on the same page (hidden until $_GET['search']) and add it with java onclick="documentgetElementById('user_name').value="<?=$user_name?>";"here's a quick run over what I stated in a verbal form:<first page><? if (isset ($_GET['add_account'])) include ("serachform.php"); ?>in searchform.php, onclick add, value of user in form on first page is set to the value from search queryI am assuming this is what you meant by autoselecting yes? Quote Link to comment https://forums.phpfreaks.com/topic/11569-select-and-copy-data-by-a-click/#findComment-43582 Share on other sites More sharing options...
.josh Posted June 9, 2006 Share Posted June 9, 2006 i think what he meant was when the user selects account info based on the account number in order to add/edit account information, he wants the known value (the account number) to be automatically put as the value in the text input field (see [b]Wisewood's[/b] post) Quote Link to comment https://forums.phpfreaks.com/topic/11569-select-and-copy-data-by-a-click/#findComment-43726 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.