Results 1 to 2 of 2

Thread: Ajax, mysql, php form

Hybrid View

  1. #1
    Join Date
    Oct 2008

    Question Ajax, mysql, php form

    Hi everyone

    I figured this forum would be the forum that would be able to help me with my issue.

    I am trying to figure out a ajax form in php. Its very simple issue and probably solution.

    Question #1:
    This is what i am trying to do. there is a price colum of a table that price is received from a mysql database, the customer will type in the ammount of plants they need and then to right of that, Ajax will display the subtotal of each plant. if the number changes in the amount they want then the ajax total will change.

    Letter sort:

    at the top of my table i have letters A-Z if a user only wants to see plants with name starting with T they press the t and it will display only plants with T. I also will have a "Display All" and it will do as it states.

    Question #2:
    I know how to display only records with say latter T but i dont know how to get that row of letters A-Z to be links that will assign variable to that letter

    <script language="javascript" type="text/javascript">
    //Browser Support Code
    function ajaxFunction(str){
    	var ajaxRequest;  // The variable that makes Ajax possible!
    		// Opera 8.0+, Firefox, Safari
    		ajaxRequest = new XMLHttpRequest();
    	} catch (e){
    		// Internet Explorer Browsers
    			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
    		} catch (e) {
    				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
    			} catch (e){
    				// Something went wrong
    				alert("Your browser broke!");
    				return false;
    	ajaxRequest.onreadystatechange = function(str){
    	if(ajaxRequest.readyState == 4){
    	var ajaxDisplay = document.getElementById('ajaxDiv');
    	ajaxDisplay.innerHTML = ajaxRequest.responseText;
    	ajaxRequest.open("POST", 'Total.php', true);
    echo "<link rel='stylesheet' href='av.css'>";
    echo "<link rel='stylesheet' href='style.css'>";
    // Open connection to DB
    include 'config.php';
    include 'opendb.php';
    $input_order = $_POST["input_order"];
    $query  = "SELECT * FROM `Availability` ORDER BY name ASC";
    $queryl  = "SELECT * FROM `Availability` Where name LIKE '$Letter%' ORDER BY name ASC ";
    $result = mysql_query($query);
    //Wrapper and button  
    <div id='center250a'>
    <div id='fixedtop2'>
    <input type='submit' />
    <div id='wrapper'>";
    echo '<form method="post" action="Total.php"> 
     Company Name:<input type="text" size="12" maxlength="40" name="cname"> <br/> Email:<input type="text" size="12" maxlength="18" name="email"><br /><br />
    // Display DB
    	"<div id='letter'>A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z
    	<table id='rounded-corner'>
    	<th scope='col' class='rounded-first'>Plant Name</th>
    	<th scope='col' class='rounded-si'>Size</th>
    	<th scope='col' class='rounded-de'>Description</th>
    	<th scope='col' class='rounded-av'>Available</th>
    	<th scope='col' align='right' class='rounded-pr'>Price</th>
    	<th scope='col' class='rounded-or'>Order Unit</th>
    	<th scope='col' class='rounded-end'>Total</th>
    	<td colspan='4' class='rounded-foot-left'>&nbsp;</td>
    	<td colspan='4' class='rounded-foot-right'>&nbsp;</td>
    while(list($id,$name,$size,$description,$available,$price)= mysql_fetch_row($result))
    	$input_order= $_POST['input_order'];
    			<td align='left'>$name</td>";
    			if ($size=='B&B')
    				echo"<td>$size"; echo '"'; echo"</td>";	
    			<td align='right'>$$price </td>
    			<form method='post' action='Total.php'>
    			<input id='input_order' onchange='ajaxFunction();' type='number' size='4' maxlength='4' name='input_order' ></td>
    			echo "Price: $price ";
    			echo "input: $input_order ";
    			echo "Total: $total<br/>";
    			<div id='ajaxDiv'>-
    echo "</tbody></table>
    // Close connection to DB
    $input_order= $_POST['input_order'];
    echo '$input_order';
    echo $price;
    	echo $total;
    echo $total;}
    My code is really messy and has a lot of unnecessary stuff in it. i will clean it all up later.

    could some one help me with my questions that would be greatly appreciated.

  2. #2
    Join Date
    Oct 2008

    One question at a time I guess

    How do i output a variable from a input using ajax.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles