Page 1 of 1

display array then edit contents

Posted: Thu Nov 17, 2005 4:46 am
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]

Posted: Thu Nov 17, 2005 4:54 am
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...

Posted: Thu Nov 17, 2005 5:15 am
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 :)

Posted: Thu Nov 17, 2005 5:22 am
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 :?:

Posted: Thu Nov 17, 2005 12:24 pm
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

Posted: Fri Nov 18, 2005 3:46 am
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:

Posted: Fri Nov 18, 2005 7:43 am
by BDKR
n00b Saibot wrote: Sometimes, you are too much...
This has me worried now. LOL! What are you trying to say?