select and copy data by a click
Posted 09 June 2006 - 10:41 AM
I 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--]
$sql = "select * from rep_table WHERE repname like '".$_GET['repname']."' and";
$sql = $sql." CUSTOMER_NAME LIKE '".$_GET['customer_name']."%'";
$result = mysql_query($sql);
echo 'Could not run query: ' . mysql_error();
echo "<table border=1 align='center' class='rep' width ='' " .
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>';
while($row = mysql_fetch_array($result, MYSQL_BOTH))
echo "<tr><td align='center'>$ACCOUNT_NO</td>
thanks in advance
Posted 09 June 2006 - 11:11 AM
Posted 09 June 2006 - 11:17 AM
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:
<? if (isset ($_GET['add_account'])) include ("serachform.php"); ?>
onclick add, value of user in form on first page is set to the value from search query
I am assuming this is what you meant by autoselecting yes?
Posted 09 June 2006 - 04:54 PM
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users