473,791 Members | 3,275 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mysql data into form for search display, editing and re-saving

2 New Member
Hi everyone. I am trying to create a web form that will let search for records. the form will display the results on a screen that will enable the viewer to edit the record and then re-save it or cancel if wanted.

I have the database. its has sample data. I can see the sample data from another machine. 'ssh'd' into the server and running mysql with appropriate commands.

I have forms to retrieve the data and display the data on the screen in a series of labels with data, with carriage return line feeds after each label and data. I need to display the data on a form that resembles the original new record entry screen.

I cannot for the life of me get the data retrieved from the database to display in the input text boxes on the form. All I get is the command syntax displayed in the text box.

please tell what I am missing. the code below contains statements built in for testing purposes. the search will not always be for a plate = METP.
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>Update Form</title>
  4. </head>
  5. <body>
  6. Vehicle Update Form<p>
  7.  
  8.  
  9. <?php
  10.  
  11. $conn = mysql_connect("localhost","root","");
  12.  
  13. mysql_select_db("impound",$conn);
  14.  
  15.  
  16. $sql = "SELECT * FROM impound_record WHERE plate = 'METP'";
  17.  
  18. $result = mysql_query($sql,$conn) or die(mysql_error());
  19.  
  20. while ($row = mysql_fetch_array(result)){
  21.  
  22. $vehid = $row['vehid'];
  23. $incident = $row['incident'];
  24. $plate = $row['plate'];
  25. $juris = $row['juris'];
  26. $vin = $row['vin'];
  27. $year = $row['year'];
  28. $make = $row['make'];
  29. $model = $row['model'];
  30. $colour = $row['colour'];
  31. $reason = $row['reason'];
  32. $location = $row['location'];
  33. $owner_name = $row['owner_name'];
  34. $owner_lic = $row['owner_lic'];
  35. $owner_address = $row['owner_address'];
  36. $released_to = $row['released_to'];
  37. $taken_by_name = $row['taken_by_name'];
  38. $taken_by_lic = $row['taken_by_lic'];
  39. $taken_by_address = $row['taken_by_address'];
  40. $driver_name = $row['driver_name'];
  41. $driver_telephone = $row['driver_telephone'];
  42. $driver_lic = $row['driver_lic'];
  43. $driver_address = $row['driver_address'];
  44. $invoice1 = $row['invoice1'];
  45. $invoice2 = $row['invoice2'];
  46. $invoice3 = $row['invoice3'];
  47. $datein = $row['datein'];
  48. $dateout = $row['dateout'];
  49. $last_record_update = $row['last_record_update'];
  50. $impound_type = $row['impound_type'];
  51. $vehkeys = $row['vehkeys'];
  52. $total_release_charge = $row['total_release_charge'];
  53. $driver_in = $row['drive_in'];
  54. $driver_out = $row['driver_out'];
  55.  
  56. ?>
  57.  
  58. <FORM ACTION="update_modified.php" METHOD=POST>
  59.  
  60. Incident Number 
  61. <input type="text" name="incident" value="<?php echo $row['incident'];?>">
  62.  
  63. Vehicle Marker 
  64. <input type=text name="plate" value="<?php echo $row['plate']; ?>" size=10>
  65.  
  66. Jurisdiction of Vehicle Marker 
  67. <input type=text name="juris" value="<?php echo $row['juris']; ?>" size=5><br>
  68.  
  69. <p>
  70. Vehicle Identification Number 
  71. <input type=text name="vin" value="<?php echo $row['vin']; ?>" size=17>
  72.  
  73. Vehicle Year of Manufacture 
  74. <input type=text name="year" value="<?php echo $row['year']; ?>" size=4>
  75.  
  76. Vehicle Make 
  77. <input type=text name="make" value="<?php echo $row['make']; ?>" size=15>
  78.  
  79. Vehicle Model 
  80. <input type=text name="model" value="<?php echo $row['model']; ?>" size=15>
  81.  
  82. Vehicle Colour 
  83. <input type=text name="colour" value="<?php echo $row['colour']; ?>" size=15><br>
  84.  
  85. <p>
  86. Reason for Impound 
  87. <input type=text name="reason" value="<?php echo $row['reason']; ?>" size=15>
  88.  
  89. Recovery Location 
  90. <input type=text name="location" value="<?php echo $row['location']; ?>" size=50><br>
  91.  
  92. <p>
  93. Owner Name 
  94. <input type=text name="owner_name" value="<?php echo $row['owner_name']; ?>" size=50>
  95.  
  96. Owner Driver License 
  97. <input type=text name="owner_lic" value="<?php echo $row['owner_lic']; ?>" size=17>
  98.  
  99. Owner Address 
  100. <input type=text name="owner_address" value="<?php echo $row['owner_address']; ?>" size=50><br>
  101.  
  102. <p>
  103. Released To 
  104. <input type=text name="released_to" value="<?php echo $row['released_to']; ?>" size=50><br>
  105.  
  106. <p>
  107. Taken By Name 
  108. <input type=text name="taken_by_name" value="<?php echo $row['taken_by_name']; ?>" size=50>
  109.  
  110. Taken By Driver License 
  111. <input type=text name="taken_by_lic" value="<?php echo $row['taken_by_lic']; ?>" size=17>
  112.  
  113. Taken By Address 
  114. <input type=text name="taken_by_address" value="<?php echo $row['taken_by_address']; ?>" size=50><br>
  115.  
  116. <p>
  117. Driver Name 
  118. <input type=text name="driver_name" value="<?php echo $row['driver_name']; ?>" size=50>
  119.  
  120. Driver Telephone 
  121. <input type=text name="driver_telephone" value="<?php echo $row['driver_telephone']; ?>" size=10>
  122.  
  123. Driver's Driver License 
  124. <input type=text name="driver_lic" value="<?php echo $row['driver_lic']; ?>" size=17>
  125.  
  126. Driver Address 
  127. <input type=text name="driver_address" value="<?php echo $row['driver_address']; ?>" size=50><br>
  128.  
  129. <p>
  130. Invoice 1 
  131. <input type=text name="invoice1" value="<?php echo $row['invoice1']; ?>" size=6>
  132.  
  133. Invoice 2 
  134. <input type=text name="invoice2" value="<?php echo $row['invoice2']; ?>" size=6>
  135.  
  136. Invoice 3 
  137. <input type=text name="invoice3" value="<?php echo $row['invoice3']; ?>" size=6>
  138.  
  139. Date Entered Facility 
  140. <input type=text name="datein" value="<?php echo $row['datein']; ?>" size=10>
  141.  
  142. Date Released from Facility 
  143. <input type=text name="dateout" value="<?php echo $row['dateout']; ?>" size=10>
  144.  
  145. Record Last Updated on 
  146. <input type=text name="last_record_update" value="<?php echo $row['last_record_update']; ?>" size=10>
  147.  
  148. <p>
  149. Impound Type 
  150. <input type=text name="impound_type" value="<?php echo $row['impound_type']; ?>" size=10>
  151.  
  152. Keys with Vehicle 
  153. <input type=text name="vehkeys" value="<?php echo $row['vehkeys']; ?>" size=1>
  154.  
  155. Total release charges 
  156. <input type=text name="total_release_charge" value="<?php echo $row['total_release_charge']; ?>" size=10>
  157.  
  158. Inbound Driver 
  159. <input type=text name="driver_in" value="<?php echo $row['driver_in']; ?>" size=5>
  160.  
  161. Outbound Driver 
  162. <input type=text name="driver_out" value="<?php echo $row['driver_out']; ?>" size=5><br>
  163.  
  164. <p>
  165.  
  166. <input type=submit name="submit" value="Update"></p>
  167.  
  168. </FORM>
  169.  
  170. }
  171.  
  172.  
  173. </body>
  174. </html>
Apr 7 '10 #1
2 7159
Atli
5,058 Recognized Expert Expert
Hey.

There is one major PHP error in there. Line #170; assuming the closing bracket is meant to close the while loop, it should be inside <?php ... ?> tags, or else it will just be assumed to be a part of the HTML, not the PHP.

The HTML is a bit of a mess, too. Tags like the <p> tag need to be closed, or everything that follows will be put inside them, even any other <p> tags that follow. I recommend you run the output this generates through the W3C HTML Validator. It shows you all the HTML errors that need to be fixed.

I cannot for the life of me get the data retrieved from the database to display in the input text boxes on the form. All I get is the command syntax displayed in the text box.
Do you get the PHP syntax in the HTML output? If you read through the HTML output in your browser (the "source"), do you see all the PHP output, including the MySQL commands (they would be hidden in the rendered page, only visible in the source), or just the syntax in the <input> boxes?

Typically when you get PHP syntax in the HTML output, your server is incorrectly configured. A common mistake is to forget to name the file .php and use .html instead. - Only .php files are executed as PHP, unless you specially configure the server to do otherwise.
Apr 7 '10 #2
metparker
2 New Member
Thanks for the help. It is all working just fine.
Apr 7 '10 #3

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

Similar topics

3
3957
by: Mike Cocker | last post by:
Hello, I'm quite weak at PHP, so I was hoping to get some help understanding the below code. First off, I'm trying to create a "query form" that will allow me to display the results on my screen. I grabbed this code from the net hoping that I could tweak it for my needs. I'm using MySQL, PHP and IIS and they all are running fine. As the code is, it will display the form, but it won't display my result(s). Any suggestions? Cheers,
3
3497
by: Lyle Fairfield | last post by:
In a recent thread there has been discussion about Data Access Pages. It has been suggested that they are not permitted on many or most secure sites. Perhaps, that it is so, although I know of no site that has this prohibition, and I have uploaded DAPs to various sites and used them from those sites. I do not understand why any site manager would prohibit DAPs. To the best of my knowledge DAPs, as HTM files, are merely hosted on the...
6
1161
by: needin4mation | last post by:
I have a set of textboxes. If it is a new record the textboxes are empty and there is a save button. If this is an existing record, I have a search form, a datagrid and the user selects form the datagrid and the same set of textboxes now populates for editing with an update button. I know I can set up a datalist or datagrid to do this "automatically," but I want two things. I want the search list to look like a datagrid, that is the...
1
2832
by: Good Man | last post by:
Hi there I've noticed some very weird things happening with my current MySQL setup on my XP Laptop, a development machine. For a while, I have been trying to get the MySQL cache to work. Despite entering the required lines to "my.ini" (the new my.cnf) through notepad AND MySQL Administrator, the cache does not work. So, today I took a peek at the 'Health' tab in MySQL Administrator.
15
4644
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to communicate with a MySQL database table on a web server, from inside of my company's Access-VBA application. I know VBA pretty well but have never before needed to do this HTTP/XML/MySQL type functions.
1
3376
by: mpar612 | last post by:
Hi everyone, I'm not sure if this is asking too much or not. I am trying to get the following PHP code to work on my website. It utilizes PHP 5, MySQL 4.1 and the PEAR DB module. I am having issues retrieving data from the form. It won't retrieve all of the data only a part of it. All of the code is below and I also attached the code for the main file. I seem to understand everything except for the last 40 or so lines of code,...
6
6268
by: onnodb | last post by:
Hi all, While working on an Access UI to a MySQL database (which should be a reasonable, low-cost, flexible interface to the DB, better than web-based, much less costly than a full-fledged .NET app or so.... is it?), I tried measuring the bandwith consumed by the Access/MyODBC/MySQL link, which came out to be, er, quite high. I fancied it would be interesting to look at the queries Access throws at MySQL through the ODBC link, so I...
4
3003
by: dac | last post by:
I am quietly going insane on this project. I've never worked on a project like this one before. All my previous sticky forms were for data entry, not editing. I don't know how to display the form with data from the database, allow the user to update it, and then display the form again with POST data. I can get the data out of the database and get the user updates back into the database, but how do I get the filled-out form back to the user...
1
2713
by: lsmamadele | last post by:
I am getting the following error messages in my search: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mamadele/public_html/BESTPLAYS/search.php on line 113 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/mamadele/public_html/BESTPLAYS/search.php on line 127 My code is below. Any help would be much appreciated. ...
2
1589
by: JackRbt | last post by:
I have contact info (name, address, phone) in a MySQL table. I read the rows with PHP and present the rows in an HTML table. What's the best way of allowing editing of any row? What I'm doing so far is to display each cell in an HTML textfield. I put an edit button and a delete button at the start of every row. Each row is within <form> tags. That way, the contents of each textfield will be submitted and can be used to update the MySQL row. ...
0
9669
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10207
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...
1
10156
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9997
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...
0
9030
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6776
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
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2916
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.