Select Field Won't Insert Name Into Text Box
Moderator: General Moderators
-
CoolAsCarlito
- Forum Contributor
- Posts: 192
- Joined: Sat May 31, 2008 3:27 pm
- Contact:
Re: Select Field Won't Insert Name Into Text Box
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
sorry it took me awhile to respond... I just got back from work. Here's why I said "selectitle" instead of "selecttitle":
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
<script src="[b]selectitle[/b].js"></script>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:
Code: Select all
var url="edittitle.php";Code: Select all
var url="getData.php";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";- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: Select Field Won't Insert Name Into Text Box
Is this a Javascript problem or a PHP problem?