Jump to content


This topic is now archived and is closed to further replies.


select and copy data by a click

Recommended Posts


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--]

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 ='' " .
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>
<td><a href='repform.php?cmd=update&account_no=$ACCOUNT_NO'>ADD</a></td></tr>";
echo "</table>";
?> [/quote]

thanks in advance

Share this post

Link to post
Share on other sites
<input type="text" value="<?php echo $ACCOUNT_NO ?>">

Share this post

Link to post
Share on other sites
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 query

I am assuming this is what you meant by autoselecting yes?

Share this post

Link to post
Share on other sites
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)

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.