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
https://forums.phpfreaks.com/topic/84612-php-javascript-xml-mysql-ajax/
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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.