Hello Guys
I attached a picture of my layout
Here in steps what am doing and what is missing
1- In the empty field i write some data that is inserted in the database when i click on the Valider button i submit onto another page and then return to this page
1-The problem is when i return to same page i want to display the data that was just added into the database.
How is that achievable ?
2-Second problem i want when click on the button at bottom called (créer) to add an empty field like the above one.How can i do that ?
Thanks in advance
8 2227
1. Store the values in a hidden field or in an array in session as well, then when you get back to this page (based on some other conditions as well) display the values in the session. But if you want to display the more recently added records, you have to do this with SQL based on your condition. (ie if User A inserts 5 records, then user B sees those records when he logs on)
2. You can do this with Javascript. see innerHTML and add element.
Cheers,
Dan
Hey Dan
Thanks for your reply.
What i need to do has nothing to do with the database.
I meant to say after i submit the data i submitted appear and the empty fields downwards remain to enter data How can i do that submit into different page or what
Thanks again .
Hey Dan
Did you give up on me?
Sarah
@sarah aziz
Hi, Sarah.
If you're submitting the form, I expect you'll be using POST or GET (method type for form). If so, you'll be able to retrieve these values from the aforementioned arrays in PHP. Consider the following: -
<!-- myhtmlform.html -->
-
<form action="myphppage.php" method="post">
-
<input type="text" name="username" value="<?php if (isset($_POST['username'])) echo $_POST['username']; ?>" />
-
</form>
-
In the value attribute of the input element we run some PHP code that says if this form element is available (already been submitted) in the POST array, print its value out. Otherwise, do nothing.
Does this help?
Mark.
Thanks Mark for your reply it worked but what if i want to return the field disabled how is that achievable?
It doesn't seem to work Mark
here is my code
index.php - $sql_role_name = mysql_query("SELECT Role_ID,Role_name,Role_real_name,email FROM 5novRoles WHERE Group_ID = ".$result["Group_ID"])
-
or die (mysql_error());
-
while ($result_role_name = mysql_fetch_array($sql_role_name))
-
{
-
echo '<form action="getData.php?" method="get">
-
<tr>
-
<input type="hidden" name="id" value="'.$result_role_name["Role_ID"].'" />
-
<td align="right" width="200">'.$result_role_name['Role_name'].'</td>
-
<td align="left" width="auto" ><input class="sd" type="text" name="r" value="'.$result_role_name['Role_real_name'].'"></input></td>
-
<td align="left" width="200" ><input class="sd" type="text" name="email" value="'.$result_role_name['email'].'"></input></td>
-
<td align="right" width="100px"><button type="submit" class="submit" style="margin-right:0px" />Valider</td>
-
</tr>
-
</form>';
-
}
submit.php - <?php
-
include('connect_to_DB.php');
-
-
$role_real_name = $_GET['r'];
-
$role_id = $_GET['id'];
-
$role_email = $_GET['email'];
-
-
//echo $role_id;
-
//echo $role_real_name;
-
-
mysql_query("UPDATE 5novRoles SET Role_real_name ='".$role_real_name.
-
"' , email ='".$role_email.
-
"'WHERE Role_ID = ".$role_id) or die (mysql_error());
-
-
header('Location:index.php');
-
?>
What should i do when return to index.php to disable the field that holds the data retrieved
This is what i have done so it would help other people
index.php - $sql_role_name = mysql_query("SELECT Role_ID,Role_name,Role_real_name,email FROM 5novRoles WHERE Group_ID = ".$result["Group_ID"])
-
or die (mysql_error());
-
while ($result_role_name = mysql_fetch_array($sql_role_name))
-
{
-
if ($result_role_name['Role_name'] != "" )
-
{
-
if($result_role_name['Role_real_name'] != "" )
-
{
-
echo '<form name="test" action="php/update.php?" method="get">
-
<tr>
-
<input type="hidden" name="id" value="'.$result_role_name["Role_ID"].'" />
-
<td align="right" width="200">'.$result_role_name['Role_name'].'</td>
-
<td align="left" width="auto" ><input class="sd" type="text" id="r" name="r" disabled value="'.$result_role_name['Role_real_name'].'"></input></td>
-
<td align="left" width="200" ><input class="sd" type="text" name="email" disabled value="'.$result_role_name['email'].'"></input></td>
-
<td align="right" width="100px"><button type="submit" disabled/>Valider</td>
-
</tr>
-
</form>';
-
// echo '<tr><td colspan="3">'.$result_role_name['Role_real_name'].'</td></tr>';
-
}
-
else if ($result_role_name['Role_real_name'] == "" )
-
{
-
echo '<form name="test" action="php/update.php?" method="get">
-
<tr>
-
<input type="hidden" name="id" value="'.$result_role_name["Role_ID"].'" />
-
<td align="right" width="200">'.$result_role_name['Role_name'].'</td>
-
<td align="left" width="auto" ><input class="sd" type="text" id="r" name="r"></input></td>
-
<td align="left" width="200" ><input class="sd" type="text" name="email"></input></td>
-
<td align="right" width="100px"><button type="submit" />Valider</td>
-
</tr>
-
</form>';
-
}
-
}
-
}
Sign in to post your reply or Sign up for a free account.
Similar topics
by: pmud |
last post by:
Hi,
I have 4 columns in my sql database table. I added a data adapter , data set
& a data grid to view this information. But the data grid is displaying those
4 columns TWICE , i.e in the data...
|
by: Fronky |
last post by:
Hope someone can help.
I am still learning, so no laughing please.
I am displaying records from a database using Response.Write(""); instead of
the usual datagrid method.
I am doing it this way...
|
by: vinayak |
last post by:
Hi
I am displaying data in Datagrid in ASP.NET with
Edit/Update functionality for each row. On the same page I
have 2 Button controls which submits the request to
server. These button controls...
|
by: MrL8Knight |
last post by:
Hello,
I am trying to build a simple php form based shopping cart using a cookie with arrays. I need to use 1 cookie because each order will have over 20 items. With that said, I realize I need to...
|
by: Brad Baker |
last post by:
I'm completely new to ASP.NET programming, so please accept my apologies in
advance for asking what is probably an obvious question. :-)
I'm trying to write a page which will display the...
|
by: jfarias |
last post by:
Hello all,
The problem I am having is in one of the datagrids I added a new column.
When I run the application data is not shown in the new column. I am using
VS.NET 2003 and am connecting to a...
|
by: David W. Fenton |
last post by:
I've been struggling the last two days with something I thought was
very easy, which is to open a web page with a form on it and
populate the form with data passed in a query string (either POST or...
|
by: Coll |
last post by:
I have a report that I run every quarter. When I opened it this
quarter, one of the subreports is not displaying. No error message -
just nothing displays where the subreport data should be. If you...
|
by: RichB |
last post by:
I am trying to get to grips with the asp.net ajaxcontrol toolkit, and am
trying to add a tabbed control to the page.
I have no problems within the aspx file, and can dynamically manipulate a...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |