473,388 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Displaying data just added into database

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
Attached Images
File Type: jpg Picture 1.jpg (19.4 KB, 145 views)
Oct 16 '09 #1
8 2227
dlite922
1,584 Expert 1GB
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
Oct 16 '09 #2
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 .
Oct 17 '09 #3
Hey Dan
Did you give up on me?

Sarah
Oct 18 '09 #4
Markus
6,050 Expert 4TB
@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:

Expand|Select|Wrap|Line Numbers
  1. <!-- myhtmlform.html -->
  2. <form action="myphppage.php" method="post">
  3.   <input type="text" name="username" value="<?php if (isset($_POST['username'])) echo $_POST['username']; ?>" />
  4. </form>
  5.  
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.
Oct 18 '09 #5
Thanks Mark for your reply it worked but what if i want to return the field disabled how is that achievable?
Oct 18 '09 #6
Markus
6,050 Expert 4TB
Using the same logic as above (check the POST index exists, and do some action based on the result). See input element attribute - disable.
Oct 18 '09 #7
It doesn't seem to work Mark
here is my code
index.php
Expand|Select|Wrap|Line Numbers
  1. $sql_role_name = mysql_query("SELECT Role_ID,Role_name,Role_real_name,email FROM 5novRoles WHERE Group_ID = ".$result["Group_ID"]) 
  2.                     or die (mysql_error());
  3. while ($result_role_name = mysql_fetch_array($sql_role_name))
  4. {
  5.     echo '<form action="getData.php?" method="get">
  6.           <tr>
  7.                     <input type="hidden" name="id" value="'.$result_role_name["Role_ID"].'" />
  8.                     <td align="right" width="200">'.$result_role_name['Role_name'].'</td>
  9.                     <td align="left" width="auto" ><input class="sd" type="text" name="r" value="'.$result_role_name['Role_real_name'].'"></input></td>
  10.                     <td align="left" width="200" ><input class="sd" type="text" name="email" value="'.$result_role_name['email'].'"></input></td>
  11.                     <td align="right" width="100px"><button type="submit" class="submit" style="margin-right:0px" />Valider</td>
  12.          </tr>
  13.          </form>';
  14. }
submit.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. include('connect_to_DB.php');
  3.  
  4. $role_real_name = $_GET['r'];
  5. $role_id = $_GET['id'];
  6. $role_email = $_GET['email'];
  7.  
  8. //echo $role_id;
  9. //echo $role_real_name;
  10.  
  11. mysql_query("UPDATE 5novRoles SET Role_real_name ='".$role_real_name.
  12.             "' , email ='".$role_email.
  13.             "'WHERE Role_ID =  ".$role_id)  or die (mysql_error());
  14.  
  15. header('Location:index.php');
  16. ?>
What should i do when return to index.php to disable the field that holds the data retrieved
Oct 18 '09 #8
This is what i have done so it would help other people
index.php

Expand|Select|Wrap|Line Numbers
  1.    $sql_role_name = mysql_query("SELECT Role_ID,Role_name,Role_real_name,email FROM 5novRoles WHERE Group_ID = ".$result["Group_ID"]) 
  2.                     or die (mysql_error());
  3. while ($result_role_name = mysql_fetch_array($sql_role_name))
  4. {
  5. if ($result_role_name['Role_name'] != "" )
  6. {
  7. if($result_role_name['Role_real_name'] != "" )
  8. {
  9. echo '<form name="test" action="php/update.php?" method="get">
  10.           <tr>
  11.                     <input type="hidden" name="id" value="'.$result_role_name["Role_ID"].'" />
  12.                     <td align="right" width="200">'.$result_role_name['Role_name'].'</td>
  13.                     <td align="left" width="auto" ><input class="sd" type="text" id="r" name="r" disabled value="'.$result_role_name['Role_real_name'].'"></input></td>
  14.                     <td align="left" width="200" ><input class="sd" type="text" name="email" disabled value="'.$result_role_name['email'].'"></input></td>
  15.                     <td align="right" width="100px"><button type="submit" disabled/>Valider</td>
  16.          </tr>
  17.          </form>';
  18.         // echo '<tr><td colspan="3">'.$result_role_name['Role_real_name'].'</td></tr>';
  19. }
  20. else if ($result_role_name['Role_real_name'] == "" )
  21. {
  22.     echo '<form name="test" action="php/update.php?" method="get">
  23.           <tr>
  24.                     <input type="hidden" name="id" value="'.$result_role_name["Role_ID"].'" />
  25.                     <td align="right" width="200">'.$result_role_name['Role_name'].'</td>
  26.                     <td align="left" width="auto" ><input class="sd" type="text" id="r" name="r"></input></td>
  27.                     <td align="left" width="200" ><input class="sd" type="text" name="email"></input></td>
  28.                     <td align="right" width="100px"><button type="submit" />Valider</td>
  29.          </tr>
  30.          </form>';
  31. }
  32. }
  33. }
Oct 19 '09 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

3
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...
0
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...
3
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...
4
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...
5
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...
1
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...
13
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...
3
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...
7
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...
0
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,...
0
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...
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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...
0
Oralloy
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,...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.