Nope... that didnt solve it..

Hi all...

Im having some trouble inserting values to my mySQL database.
I have the following installed on my local system.

Server: localhost via TCP/IP
Server version: 5.1.43-community
Protocol version: 10
User: root@localhost
MySQL charset: UTF-8 Unicode (utf8)
[B]Web server[/B]
Apache/2.2.14 (Win32) PHP/5.2.12
MySQL client version: 5.0.51a
PHP extension: mysql
Version information: 3.2.5


Windows 7 Home Premium


Manufacturer Hewlett-Packard
Model HP Pavilion dv6 Notebook PC
Total amount of system memory 4.00 GB RAM
System type 64-bit operating system
Number of processor cores 2


Total size of hard disk(s) 466 GB
Disk partition (C:) 388 GB Free (452 GB Total)
Disk partition (D:) 2 GB Free (13 GB Total)
Disk partition (E:) 92 MB Free (99 MB Total)
Media drive (F:) CD/DVD


Display adapter type Intel(R) Graphics Media Accelerator HD
Total available graphics memory 1696 MB
Dedicated graphics memory 32 MB
Dedicated system memory 32 MB
Shared system memory 1632 MB
Display adapter driver version
Primary monitor resolution 1366x768
Secondary monitor resolution 1280x1024
DirectX version DirectX 10


Network Adapter Intel(R) WiFi Link 1000 BGN

I can connect to the database fine.
I can select data and display it on any page with no problems.
I can even update an entry in the database from php.
I can insert, update, delete, and do any normal function from phpMyAdmin.

The problem comes when I try to insert a new set of values in a table that exists using PHP.

This is ...

Ive been looking around and havent been able to find anything like this yet.. I am new to mySQL.

Im looking for a function like the "where" function of a query string.. but insted of it being exact i would like to select "where" datafield "contains" text..


item is listed under multiple states
id=1 name=apple state=FL, WI, CA
id=2 name=orange state=FL

when displaying results i would like to have apple come up when i select any of the states that it is listed under..

any questions?


Thank you very much!

I did look around on the web a bit for the answer but kept finding ways to pull the whole row out.. I even tryed to find a answer on Sorry for asking such a basic question ill try to look a little harder next time.

Thanks so much



I have a question about pulling a value from a mySQL DB.

Wondering how you pull just one value out of a list..

Table name is People






How would I display just Jim Boberson's age on a page.. nothing else.

Also how would I insted of displaying his age on the page just set it to a variable called $jimbobage?


Ok I have been playing around with some code and have found this example that does most of what I would like.


//set IE read from page only not read from cache
header ("Expires: Sun, 03 Feb 1997 04:22:00 GMT");
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header ("Cache-Control: no-cache, must-revalidate");
header ("Pragma: no-cache");

 header("content-type: application/x-javascript; charset=tis-620");


 //set database

$dbhost = "localhost";
$dbuser = "";
$dbpass = "
$dbname = "****";
mysql_pconnect($dbhost,$dbuser,$dbpass) or die ("Unable to connect to MySQL server");

 if ($data=='states') {  // first dropdown
      echo "<select name='states' onChange=\"dochange('cities', this.value)\">\n";
      echo "<option value='0'>==== choose state ====</option>\n";
      $result=mysql_db_query($dbname,"select `id`, `state` from states order by `state`");
      while(list($id, $name)=mysql_fetch_array($result)){
           echo "<option value=\"$id\" >$name</option> \n" ;
 } else if ($data=='cities') { // second dropdown
      echo "<select name='cities' >\n";
      echo "<option value='0'>====choose cities ====</option>\n";                           
      $result=mysql_db_query($dbname,"SELECT `id`, `city` FROM cities WHERE `state_id` = '$val' ORDER BY `city` ");
      while(list($id, $name)=mysql_fetch_array($result)){       
           echo "<option value=\"$id\" >$name</option> \n" ;
 echo "</select>\n";



echo "<form name=sel>\n";
echo "States : <font id=states><select>\n";
echo "<option value='0'>============</option> \n" ;
echo "</select></font>\n";

 echo "Cities : <font id=cities><select>\n";
 echo "<option value='0'>=== none ===</option> \n" ;
 echo "</select></font>\n";


<script language=Javascript>
function Inint_AJAX() {
try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {} //IE
try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {} //IE
try { return new XMLHttpRequest(); } catch(e) {} //Native Javascript
alert("XMLHttpRequest not supported");
return null;

function dochange(src, val) {
var req = Inint_AJAX(); ...


Im new to PHP and have a need for what I have found out is called AJAX.
I prefer to code in PHP for my DB access.
I need to create a dropdown list using AJAX that updates it self depending on what is slected in the parent dropdown list.
To make matters worse.. It needs to be reliant on a database.

Here is an example of what I would like to achieve.

Ill try to be as clear as I can be.



            |             |              |                  |    
           NEW          USED          CLASSIC          COMMERICAL
            |             |              |                  |    
            |             |              |                  |    
            |             |              |                  |    
          Types         Types          Types              Types  
            |             |              |                  |    
         -------       -------        -------            ------- 
        |       |     |       |      |       |          |       |
       GM      FORD   GM     FORD    GM     FORD       GM    FORD
        |       |     |       |      |       |          |       |
        |       |     |       |      |       |          |       |
        |       |     |       |      |       |          |       |
        |       |     |       |      |       |          |       |


I would like the dropdown to flow in this order.. "Example of a user using the dropdown."

User selects from the dropdown the State of choice from the list available.(The "State" dropdown is populated using data from the SQL DB.. example states available "New York", "Florida", and "Vermont")

User selects "New York"(all available "Conditions" in "New York" are loaded into the next dropdown)

User then selects the condition from the next dropdown.. ...

Moving this to the Ajax forum.. thanks for the help!

Ok I have all that set up and a connection to my DB.
Im a pretty big newb.. what should my DB structure look like for this example to work ex: tables and such.. Im using PHPmyAdmin to edit my DB..


Thanks again! Ill see what I can do.. you were very helpful!


suppose i allow a page refresh to update the form what would it look like/ how well do you think it would work?

Thanks again,

I would like to do the form in PHP if possible. I will be creating a form with values that will constantly be changing/ added to. Im going to build a simple back end to add/ remove DB entrys.

In the end when a user hits submit the form will get a list of results and display it on the same page if possible or on a different page if need be. Kind of like when you have a PHP searh on a site.

The example provided. "" is only being referenced for its dynamic field abilities. My form will not have a "Language" option.. that form is for reference only.

Basicly I just need find a way to make a PHP form where as you click a drop down box.. depending on what you select from that box, the next box displayed has different content in it.



IF value A selected this box displays
IF value B selected this box displays
IF value C selected this box displays

and so on.. with each box following depending on the previous box..



Wondering if someone could give me a hand.. Im looking to make a form kind of like this one.. ""

Where the fields change depending on what is slected.. I would like to link the values of the of the form to a mySQL DB. So the form when loaded askes the DB what values to display. The end result would be a list of results searched by the form.

very much like the form listed above.. but what im really hanging up on is the changing what fields are showing..