473,396 Members | 2,129 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,396 software developers and data experts.

How do I select this type of data using MySQL and PHP?

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. require_once('connect.php');
  4.  
  5. if(isset($_POST['but'])) {
  6.  
  7. mysqli_select_db($connect, "d");
  8.  
  9. $result = mysqli_query($connect, "SELECT name FROM find");
  10.  
  11. $row = mysqli_fetch_array($result);
  12.  
  13. $insert = "INSERT INTO but (sessionusername,onname,email) VALUES ('" . $_SESSION['username'] . "','" . $row['name'] . "','" . $row['email'] . "')";
  14.  
  15. $done = mysqli_query($connect,$insert) or die(mysql_error());
  16.  
  17.  
  18. if($done)
  19. {
  20.     echo "Awesome";
  21. }
  22. else
  23. {
  24.     echo "Error";
  25. }
  26. }
  27. ?>
  28.  
  29. <html>
  30. <body>
  31. <form action="but.php" method="post">
  32. <input type="submit" name="but" value="Review" />
  33. </form>
  34. </body>
  35. </html>
  36.  
I have placed this button in the end of every row in an html table. On clickin this button, i want it to enter the session username and name and email of the ROW on which the button was clicked.

With this, if I click on the button in the first row, it inserts all the possible names and emails from every row. How do i fix that?

Thanks for all your help.
Nov 8 '10 #1
2 1898
code green
1,726 Expert 1GB
This query wil get every name from find
Expand|Select|Wrap|Line Numbers
  1. $result = mysqli_query($connect, "SELECT name FROM find"); 
  2.  
It needs modifying so that only the record that matches a $_POST form entry is returned
Nov 9 '10 #2
thanks dear for providing info
Feb 3 '11 #3

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

Similar topics

24
by: Ehud Shabtai | last post by:
Hi, I would like to store samples of data which are gathered from about 500 devices in mysql. Each device has its own data which changes over time. The data may be integer or float. The...
3
by: Sven Reifegerste | last post by:
Hi, i have a table with INT columns id,key,b1,b2,c1,c2, having 1.500.000 rows. 'key' and 'id' are indexed (Kardinality 385381) and id (Kardinality 1541525). Performing a SELECT * FROM...
3
by: filip.norrgard | last post by:
Hi All! I've been developing an ASP.Net 2.0 web application using the Visual Studio 2005 tools. Currently datagrids on a page are filled with data from a dataset (a .xsd file in the "project")...
1
by: sonasiva | last post by:
Hai . iam doing my project(website) using ASP I have data in database as like as follows NO Name Companyname Shares Date 1 anish xxx ...
6
wadro21
by: wadro21 | last post by:
Hello everyone, i am trying to pull from a myql database all records from a table with multiple rows. i need to be able to call the data from each row one by one i would asume from an array. the...
0
by: John Kirkpatrick | last post by:
Hi all, I am having difficulty displaying records on a frontend MS Access 2000 form using a MySQL backend. The following code works well with the Jet database engine but doesn't work properly...
1
by: runsun | last post by:
I am new in PHP/Mysql. I want to input sth from website to mysql, then output the formatted data to .txt, and finally use Excel to open the .txt file. I believe there are better and simpler ways than...
2
by: mfaisalwarraich | last post by:
Hi Everybody, I am using the following function to get the data from mysql database. i have entered appnum field as text filed in the database which has leading zeroes to this field like if...
2
by: sarah aziz | last post by:
Hello all I am trying to retrieve the data from mysql database by php to plot a flot graph can anyone help me please this is all i have done for now Php $sql = mysql_query("SELECT count(Msg_ID)...
1
by: ghjk | last post by:
When I retriwe data from mysql I got an error saying "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\xxxr\xxx.php on line 34"....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.