display array then edit contents

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

Post Reply
spitfire_esquive
Forum Commoner
Posts: 37
Joined: Sun Nov 06, 2005 6:46 am

display array then edit contents

Post by spitfire_esquive »

[Moderator note:] This was moved from Theory & Design to PHP-Code.

hi! i have this code where the results are placed in an array and then i used an text input so that i could edit the contents of that array :

Code: Select all

if ($num_results == 0)
	{
	echo "No name in the database.";
	exit;
	}
	else
	{
		for ($i=0; $i < $num_results; $i++)
		{
			$row = mysql_fetch_array($result);
			echo '<p><strong>'.($i+1).'.ClientID: ';
			echo htmlspecialchars($row['id']);
			$id=htmlspecialchars($row['id']);
			echo "<p><a href='http://localhost/ewan2.php?id=$id'>Enter query for this client</a></p>";
			echo '<p><strong><br /> Name:';
?>
<input type="text" value="<?php echo $row['name']?>">

<?php
			echo htmlspecialchars($row['name']);
			echo "</br>-=-=-=-=-=-=-=";
		}

	}

?>
i would just like to know if it is possible? if it is i would put a submit button at the end of the page and it would trigger an update function in mysql.

comments are much appreciated!

thanks!

twigletmac | Please use

Code: Select all

tags when posting PHP code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

yeah! it is very much possible but the submit will not magically update the DB, you will have to process that too...
spitfire_esquive
Forum Commoner
Posts: 37
Joined: Sun Nov 06, 2005 6:46 am

Post by spitfire_esquive »

thanks n00b :) was planning to use javascript as i will be including the code in the same page. javascript will capture the onClick (or is it onSubmit?) event.

will try to make it work :)
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

spitfire_esquive wrote:javascript will capture the onClick (or is it onSubmit?) event
and then what will JS do with it... insert into DB :?: what do you plan to do with JS :?:
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

He could use asynchronous javascript calls to a call back function that could affect change to the array server side without a page refresh.

However, that's beyond the scope of what we're talking about here I suspect.

So, err....., yeah.... Just use Javascript and a form to capture the changes you want made to the array then submit it back.

Cheers,
BDKR
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

BDKR wrote:He could use asynchronous javascript calls to a call back function that could affect change to the array server side without a page refresh.

However, that's beyond the scope of what we're talking about here I suspect.

So, err....., yeah.... Just use Javascript and a form to capture the changes you want made to the array then submit it back.
Sometimes, you are too much... you would confuse him thoroughly :lol:

*thinks: Maybe I should start using geek, techy terms now onwards. its pretty fun*

So.. um..yeah... He could use asynchronous javascript calls to a call back function that could affect change to the array in the database on the server side without a page being submitted to the server :lol:
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

n00b Saibot wrote: Sometimes, you are too much...
This has me worried now. LOL! What are you trying to say?
Post Reply