473,800 Members | 2,388 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

displaying data fetched from mysql

59 New Member
Hi,

For my project I have a "add" button, upon clicking it, it will take the user to next page where there will be a text box and list of data displayed below it which is fetched from mysql database. I have written the code for this which is working fine. But I have a problem, i.e. when user enters the code in text box and clicks "go" button a group of data will be fetched from the database and should be displayed below the text box, where previously the mysql group of data was displayed i.e. the new group of data fetched from mysql database should replace the old group of data. I hope you got my point.

For eg, when the user clicks add link in pageone.php page he will send the nameid=2, and mysql data for this nameid will be fetched from mysql and displayed below the textbox in pageload.php page. But in pageload.php page the user will be having option to enter his own nameid and search results for that. So when he clicks the go button, mysql data for this nameid should be fetched and displayed in the place of previous data. There should not be 2 set of data displayed. How can I do this

How will I do this, please give me some idea

Here is the code I have written

pgaeone.php

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3. <a href="pageload.php?nameid=2">ADD</a> 
  4. </body>
  5. </html>

pageload.php

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3. <form name="load" action="" method="POST">
  4. please enter code
  5. <input type="text" name="sel">
  6. <input type="submit" value="go" name="sub">
  7. </form>
  8. <?php
  9.     $id = $_GET['nameid'];
  10.  
  11.     $sql = "SELECT name FROM TEBLE1 WHERE nameid='$id'";
  12.     $result = mysql_query($sql);
  13.     while ($values = mysql_fetch_array($result))
  14.     {
  15.         echo $values['0'];
  16.         echo "<br>";  
  17.     }
  18.  
  19. ?>
  20. </body>
  21. </html>
Please help.


With regards
May 19 '08 #1
1 1789
TheServant
1,168 Recognized Expert Top Contributor
A few things, first, I think you are collecting something else. You have your form POSTing, and then your php is GETting. You have no action, so if you are POSTing I think you want to send the data to itself by using something like:
[php]action="<?php echo $_SERVER['REQUEST_URI']; ?>"[/php]
and then change your $id to $_POST['nameid'].

That brings me to my next point, where is "nameid" given? Your text input is called sel? So shouldn't your code have $id=$_GET['sel']?

If you don't have all your code and have addressed the above problems there, say so and we can move on. If you don't understand what I have asked/suggested, then let me know how much PHP you have done, so I can suggest some good tutorials.

For the fact that new lines are being added, I think it's because you have a while loop in there.

Try this:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3. <form name="load" action="" method="POST">
  4. please enter code
  5. <input type="text" name="sel">
  6. <input type="submit" value="go" name="sub">
  7. </form>
  8. <?php
  9.     $id = $_GET['nameid'];
  10.  
  11.     $sql = "SELECT name FROM TEBLE1 WHERE nameid='$id'";
  12.     $result = mysql_query($sql);
  13.     {
  14.         echo ( $result."<br />" ) ;
  15.     }
  16.  
  17. ?>
  18. </body>
  19. </html>
May 19 '08 #2

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

Similar topics

9
7043
by: Philip D Heady | last post by:
Ok, as some of you may know I'm an Oracle newbie w/ PHP. I'd rather use MySQL but at the office here we use Oracle and boy do I have alot to learn. I'm starting to hate it after using MySQL!! -------------------------------------------------------------------------- 1) Is there a similar statement using PHP/Oracle functions as below for MySQL? -------------------------------------------------------------------------- while (list...
1
508
by: Dave Posh | last post by:
I seem to be having a problem displaying time stored in mysql. The format stored in the database is 13:15:05. The database data type is time. I'm using asp vbscript and sql to retrieve the time store in the database. However asp recognizes the data type as date and displays the date instead of the time. If I change the data type in mysql to varchar then asp will display the time correctly, but I cannot do it this way. I want to be able...
0
2090
by: David List | last post by:
I am wondering what I miss to be able to handle binary data from the mysql client. I have ensured that the user has file_priv set to 'Y' and that max_allowed_packet is larger that the binary lumps handled. Here is my version: Ver 4.1.5-gamma-log for pc-linux on i686 (Source distribution) Right now I'm trying this to insert binary data: mysql> update table set col=load_file("/path/file") where id=1;
3
1506
by: Ifoel | last post by:
Hi all pls help me How to know "HOW MANY SECOND" we fetched the rows of the record MySQL via Visual Basic 6...? Sample: 321 rows Fetched in 0,234s -> i need this field to load on the FORM VB thanks in advance
6
1631
by: kumuda v | last post by:
Hello all, How to diaplay the email ID fetched from the mysql database as an hyperlink using php and html With regards, kumuda
1
14058
by: preejith | last post by:
Error Code : 1329, No data - zero rows fetched, selected, or processed. MYSQL I am getting the following error while running a stored procedure in mysql5.0 Error Code : 1329 No data - zero rows fetched, selected, or processed. I have an stored procedure SP1 which calls stored procedure SP2 and SP2 calls a function F1. I have run this script from .bat file.
9
7384
by: Gilles Ganault | last post by:
Hello Some data are common to all user sessions, and to improve performance/save resources, I'd like to share those data between all sessions, so that each user doesn't have to hit MySQL for the same data. I'd rather avoid writing those in a flat file, and keep stuff in RAM instead. Someone told me about cache servers like MemCacheD. I was also given the hints of writing in OO (public class variables) or using
0
10514
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10287
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10042
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7588
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6826
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5479
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5616
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4156
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3770
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.