473,750 Members | 2,559 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using UPDATE in MySQL

I have an input form that passes data when submitted to a second form
to let the user know what they have just entered into the db.

My question comes with using 'update'. I'd like to query the database
by equipment number (equipno is unique) and query all fields from that
row, populating an original form 'look alike' whereby the user can add
detail to the original records as the db builds. I'm using 'date'
twice because I'd like to have the original date the record was added
plus the most recent update date.

Form 1 below, is original user input:
<html>
<head>
<title>Equip Input</title>
</head>
<body>
<center><h3>Equ ipment Input</h3></center>
<form method="post" action="updatin gin2.php">
<input type="hidden" name="id" value="NULL">
<input type="hidden" name="date1" value="<? print
strftime("%m/%d/%Y"); ?>">
<center>
<table border="8">
<tr>
<td>Date:</td>
<td align="left"><i nput type="text" name="date2" size="8"
maxlength="10" value="<? print strftime("%m/%d/%Y"); ?>"></td>
</tr>
<tr>
<td>Equipment Number:</td><td align="left"><i nput type="text"
name="equipno" size="25" maxlength="15" value=""></td>
</tr>
<tr>
<td>Equipment Name:</td><td align="left"><i nput type="text"
name="equipname " size="25" maxlength="25" value=""></td>
</tr>
<tr>
<td>Equipment Model No:</td><td align="left"><i nput type="text"
name="model" size="25" maxlength="6" value=""></td>
</tr>
<tr>
<td>Equipment Serial No:</td><td align="left"><i nput type="text"
name="serial" size="25" maxlength="6" value=""></td>
</tr>
<tr>
<td colspan="4" align="center"> <input type="submit"
value="Enter"></td>
</tr>
</table>
</form>
</center><p>
</body>
</html>

Form 2 below shows data that has been input to the db:
<html>
<head>
<title>Equipmen t Input Form Results</title>
</head>
<body>
<font color="#990099" size="+1"><span style="font-size:18"><p>
<TABLE cellSpacing=0 cellPadding=10 width="85%" align=center
border=8">
<TBODY><TR><T D vAlign=top align=left><P>< FONT face=arial color=bright
white><b>
<?php
$DBhost = "localhost" ; // connection information
$DBuser = "john";
$DBpass = "jco234";
$DBName = "updatingin ";
$table = "updatingin_tbl ";

$id = $_POST['id'];
$date1 = $_POST['date1'];
$date2 = $_POST['date2'];
$equipno = $_POST['equipno'];
$equipname = $_POST['equipname'];
$model = $_POST['model'];
$serial = $_POST['serial'];

mysql_connect($ DBhost,$DBuser, $DBpass) or die("Unable to connect to
database"); // make connection to database
mysql_select_db ($DBName) or die("Unable to select database $DBName");
// select database
// if (mysqli_connect _errno()) removed for go live 7/21/05
// {
// echo 'Error: Could not connect to database. Please report this
problem to Chris Overland.';
// exit;
// }
$sqlquery = "INSERT INTO $table (id, date1, date2, equipno, equipname,
model, serial) VALUES('$id', '$date1', '$date2', '$equipno',
'$equipname', '$model', '$serial')";
$results = mysql_query($sq lquery) or die("Query failed: $sqlquery<br>"
..
mysql_error());
echo mysql_error();
mysql_close();
print "<center><t able border=\"0\"
width=\"500\">< tr><td>";
print "<p><font face=\"verdana\ " size=\"+0\"> <center>You
Just Entered This Information into the Database<p><blo ckquote>";
print "Date: $date2<p>Equipm ent Number: $equipno<p>Equi pment Name:
$equipname<p>Mo del: $model<p>Serial :
$serial</blockquote></td></tr></table>
</CENTER>
</body>
</html>";
?>
</FONT></CENTER></b>
</H3></TD></TR></TBODY></TABLE>
</body>
</html><p>

Form 3 below shows where I hope to query results from the db
(updatingin) and place them into my form 1 'look alike' which would be
for updating records. Hope that makes sense. Finally, I would VERY
much appreciate any pointers on getting the form data to show in my
update form. TIA and gratefully yours, :-) Chris

<html>
<head>
<title>Equip Update</title>
</head>
<body>
<center><h3>Equ ipment Input</h3></center>
<form method="post" action="updatin gin2.php">
<input type="hidden" name="date2" value="<? print
strftime("%m/%d/%Y"); ?>">
<center>
<table border="8">
<tr>
<td>id:</td><td align="left"><i nput type="text" name="id" size="25"
maxlength="15" value=""></td>
</tr>
<tr>
<td>Equipment Number:</td><td align="left"><i nput type="text"
name="equipno" size="25" maxlength="15" value=""></td>
</tr>
<tr>
<td>Equipment Name:</td><td align="left"><i nput type="text"
name="equipname " size="25" maxlength="25" value=""></td>
</tr>
<tr>
<td>Equipment Model No:</td><td align="left"><i nput type="text"
name="model" size="25" maxlength="6" value=""></td>
</tr>
<tr>
<td>Equipment Serial No:</td><td align="left"><i nput type="text"
name="serial" size="25" maxlength="6" value=""></td>
</tr>
<tr>
<td colspan="4" align="center"> <input type="submit" value="Update
Record"></td>
</tr>
</table>
</form>
</center><p>
</body>
</html>
Apr 22 '06 #1
5 2200
On Sat, 22 Apr 2006 10:59:05 -0700, cover wrote:

So I guess in short, what I'm looking for is a single field text
search to populate table 3 where the successful query result of this
form:

<html>
<head>
<title>Equip Update Search</title>
</head>
<body>
<center><h3>Equ ipment Update Search</h3></center>
<form method="post" action="updatin gin4.php">
<center>
<table border="8">
<tr>
<td>Equipment Number:</td><td align="left"><i nput type="text"
name="equipno" size="25" maxlength="15" value=""></td>
</tr>
<tr>
<td colspan="4" align="center"> <input type="submit"
value="Search"> </td>
</tr>
</table>
</form>
</center><p>
</body>
</html>

Populates the form below where an 'equipno' is found in the db:

<html>
<head>
<title>Equip Update</title>
</head>
<body>
<center><h3>Equ ipment Update</h3></center>
<form method="post" action="updatin gin2.php">
<input type="hidden" name="date2" value="<? print
strftime("%m/%d/%Y"); ?>">
<center>
<table border="8">
<tr>
<td>id:</td><td align="left"><i nput type="text" name="id" size="25"
maxlength="15" value=""></td>
</tr>
<tr>
<td>Equipment Number:</td><td align="left"><i nput type="text"
name="equipno" size="25" maxlength="15" value=""></td>
</tr>
<tr>
<td>Equipment Name:</td><td align="left"><i nput type="text"
name="equipname " size="25" maxlength="25" value=""></td>
</tr>
<tr>
<td>Equipment Model No:</td><td align="left"><i nput type="text"
name="model" size="25" maxlength="6" value=""></td>
</tr>
<tr>
<td>Equipment Serial No:</td><td align="left"><i nput type="text"
name="serial" size="25" maxlength="6" value=""></td>
</tr>
<tr>
<td colspan="4" align="center"> <input type="submit" value="Update
Record"></td>
</tr>
</table>
</form>
</center><p>
</body>
</html>
Apr 22 '06 #2
In message <3a************ *************** *****@4ax.com>, cover
<co************ ****@yahoo.com> writes
On Sat, 22 Apr 2006 10:59:05 -0700, cover wrote:

So I guess in short, what I'm looking for is a single field text
search to populate table 3 where the successful query result of this
form:


$find=$_POST['equipno'];
$table = /* name of your MySQL table */

/* Connect and select your database as in input file */

$item = mysql_query("SE LECT * FROM $table WHERE equipno = '$find'");

Then:
$item['id'] is your id;
$item['date1'] is your first date;
$item['date2'] is your second date;

etc.

--
Martin Jay
Apr 24 '06 #3
In message <AB************ **@spam-free.org.uk>, Martin Jay
<ma****@spam-free.org.uk> writes
In message <3a************ *************** *****@4ax.com>, cover
<co*********** *****@yahoo.com > writes
On Sat, 22 Apr 2006 10:59:05 -0700, cover wrote:

So I guess in short, what I'm looking for is a single field text
search to populate table 3 where the successful query result of this
form:


$find=$_POST['equipno'];
$table = /* name of your MySQL table */

/* Connect and select your database as in input file */

$item = mysql_query("SE LECT * FROM $table WHERE equipno = '$find'");

Then:
$item['id'] is your id;
$item['date1'] is your first date;
$item['date2'] is your second date;

etc.


Ooops, I forgot about mysql_fetch_arr ay, it should be something like:

$item = mysql_query("SE LECT * FROM $table WHERE equipno = '$find'");
$row = mysql_fetch_arr ay($list);

Then:

$row['id'] is your id;
$row['date1'] is your first date;
$row['date2'] is your second date;
--
Martin Jay
Apr 24 '06 #4
Martin Jay wrote:
In message <3a************ *************** *****@4ax.com>, cover
<co************ ****@yahoo.com> writes
On Sat, 22 Apr 2006 10:59:05 -0700, cover wrote:

So I guess in short, what I'm looking for is a single field text
search to populate table 3 where the successful query result of this
form:

$find=$_POST['equipno'];
$table = /* name of your MySQL table */

/* Connect and select your database as in input file */

$item = mysql_query("SE LECT * FROM $table WHERE equipno = '$find'");

Then:
$item['id'] is your id;
$item['date1'] is your first date;
$item['date2'] is your second date;

etc.


Not quite.

$result = mysql_query("SE LECT * FROM $table WHERE equipno = '$find'");
$item = mysql_fetch_arr ay($result);

NOW:
$item['id'] is your id;
$item['date1'] is your first date;
$item['date2'] is your second date;

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Apr 24 '06 #5
Thanks very much guys - appreciate the help. :-)
Apr 26 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
5657
by: Gary | last post by:
I haver a table of students - Say 100 students that I need to be able to update/delete and amend. I know I can do this one student at a time which is simple but lets say I want to see all the students on the screen at the same time, modify some, mark some for deletion and even have blank fields at the end to add a new record. In HTML which is generated I label each row and input field with a name/number combination i.e <input type=text...
0
5913
by: Fraser Hanson | last post by:
Hello, I have a table which has a foreign key relationship with itself. I want and expect my updates to cascade (deletes definitely cascade as expected) but instead I just get error 1217: foriegn key error. I have written example code to use in reproducing the problem: # Create the table
0
5357
by: Jim S. | last post by:
I'm having a horrible time simply inserting the date in a MySQL database through a Visual Basic program. I have a table, called "ORDERS"; "ID" is the primary key. I'm trying the insert the date, into the MySQL database, which is a DATETIME datatype. I must keep it DATETIME so it can be accessed via Microsoft Access. Here are two versions of the program. The first one fails, with the "Row cannot be located for updating. Some values may...
17
5028
by: kalamos | last post by:
This statement fails update ded_temp a set a.balance = (select sum(b.ln_amt) from ded_temp b where a.cust_no = b.cust_no and a.ded_type_cd = b.ded_type_cd and a.chk_no = b.chk_no group by cust_no, ded_type_cd, chk_no)
7
11483
by: sime | last post by:
Hi, I have a blob field in a mysql database table. I want to copy a blob from one record to another. I am having trouble transferring the data via a php variable. Maybe I need to addslashes or convert to Hex or something. I've tried a few things but can't quite get it. Here is simplified code. mysql_select_db($dbname, $connection);
4
2717
by: Japhy | last post by:
Hello, I'm am pulling data from a mysql db and want to use the data to populate a <ul. Here are relavent parts of my code : $wohdate = mysql_result($wohRS,$wohndx,woh_date); $woh_display .="<li>".$wohdate."</li>" ; $TemplateText = Replace($TemplateText,"@$wohdisplayndx@",$woh_display);
4
7458
by: The Bear | last post by:
Has anyone successfully used MySQL with C#? I'm having problems using the Update command Here is the code snippet. I am able to connect to the database. However when I try to update the database with the changes in the dataset I get the following error: An unhandled exception of type 'System.InvalidOperationException' occurred
9
4805
by: =?iso-8859-1?B?Sm/jbyBNb3JhaXM=?= | last post by:
Hi there guys, My doubt is related with MySQL and Transactions (InnoDB) so here it goes: I have a query like this: $query = 'START TRANSACTION; '; $query .= 'UPDATE sections '; $query .= 'SET position=position-%d ';
3
9121
by: RAG2007 | last post by:
I'm using the QueryDef and Execute method to update a record in my MySQL backend. Problem: When the Passthrough update query is defined using QueryDef, it becomes a select query, and I cannot use the Execute Method. Instance: The following code is defined as a query called "AddCost" UPDATE tblinitiative SET tblinitiative.Estimate = " & Estimate & ", tblinitiative.FinalCost = " & FinalCost & " WHERE (((tblinitiative.InitID)=" & InitID &...
0
4439
by: silversubey | last post by:
I am trying to convert mssql triggers to mysql. I am very new to Mysql and would like some help with my code. My queries work but there has to be a more efficient way to write them. I would greatly appreciate any help. the following is a trigger that works until I add the last update statement. thanks for the help. Mysql 5 delimiter // Create TRIGGER User_Rating_Avg After Insert on bksite.Ratings FOR EACH ROW BEGIN UPDATE...
0
9001
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
9584
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...
1
9345
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
9257
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
8265
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
4716
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
4894
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3327
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
2809
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.