Page 2 of 2
Re: Select Field Won't Insert Name Into Text Box
Posted: Tue Aug 05, 2008 4:09 pm
by CoolAsCarlito
okay I did what you wanted and tested it and you almost have me with what I'm needing. Thank you for getting me this far however it's putting in a different value so maybe you'll easily figure out from there.
Re: Select Field Won't Insert Name Into Text Box
Posted: Tue Aug 05, 2008 4:23 pm
by Chalks
sorry it took me awhile to respond... I just got back from work. Here's why I said "selectitle" instead of "selecttitle":
Code: Select all
<script src="[b]selectitle[/b].js"></script>
you need to change that to selecttitle.js
edit: never mind, I see that you changed it. you now need a third file. Call it "getData.php" (or whatever). Then, edit this line of the javascript:
to
getData.php should be something like:
Code: Select all
<?php
if(isset($_GET['q']) && !empty($_GET['q']))
{
$q = $_GET['q'];
mysql_connect("localhost", "username", "password");
mysql_select_db("database name");
$q = mysql_real_escape_string($q);
$sql = "SELECT title FROM table WHERE title='$q'";
$result = mysql_query($sql)
if($data = mysql_fetch_assoc($result))
echo $data['title'];
else
echo "error, please try again";
mysql_close();
}
else
echo "error, please try again";
Re: Select Field Won't Insert Name Into Text Box
Posted: Tue Aug 05, 2008 4:48 pm
by RobertGonzalez
Is this a Javascript problem or a PHP problem?