Select Field Won't Insert Name Into Text Box

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

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

Post 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.
User avatar
Chalks
Forum Contributor
Posts: 447
Joined: Thu Jul 12, 2007 7:55 am
Location: Indiana

Re: Select Field Won't Insert Name Into Text Box

Post 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:

Code: Select all

var url="edittitle.php";
to

Code: Select all

var url="getData.php";
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";
User avatar
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

Post by RobertGonzalez »

Is this a Javascript problem or a PHP problem?
Post Reply