Jump to content

PHP JAVASCRIPT XML MYSQL AJAX


ajaxl

Recommended Posts

Hi I am a total nube with ajax (in fact just broke the ice with it today) I have created a link to mysql database and can view these records as well. I am trying to create a form that will edit the details that are displayed as well.

 

This will update when i hit the Update button but only the first line is this a common problem. Any help would be great.

 

Here is the html and function from my ajax app i can post more if it is useful.

 

HTML/PHP

 

while($row = mysql_fetch_array($result))

{

echo "<form name='meals".$row['ID']."'>";

echo "<input type='text' id='itemID' value='".$row['ID']."'/> ";

echo "<input type='text' id='mealName' value='". $row['mealName'] ."' /><input type='button' onClick='updateRequest();' value='Update' /> <a href='javascript:deleteRequest('".$row['ID']."');'>Delete</a>";

echo "<br/>";

echo "</form>";

}

 

mysql_close($con);

 

 

 

XML/JAVASCRIPT.

 

 

function updateRequest() {

var url="update.php";

//xmlHttp.open('get', 'update.php?' + mealName + '&ID=' + ID);

var mealName = document.getElementById('mealName').value;

var ID = document.getElementById('itemID').value;

 

url=url+"?mealName="+mealName;

url=url+"&ID="+ID;

 

xmlHttp.open("GET",url,true);

 

xmlHttp.onreadystatechange = handleResponse;

xmlHttp.send(null);

}

 

thanks :-[

Link to comment
Share on other sites

Hi,

 

You are creating multiple forms??? I think to update any row your don't need a form .My advice would be create your <from> tab above the while loop and inside the loop try to make the form fields.It will ease your task.

 

Let me know if you feel some problem after this.

 

regards

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.