Jump to content

Adding a simple "update details" form.


colleyboy

Recommended Posts

I have a simple form to add details to the database.

 

I want to use the same form layout to call back details for editting and updating.

 

The main page is showroomedit.php which lists (in an array) the records in the database.

 

I have added an edit.php but cant seem to work the code out.  Can some one point me in the right direction. :D

 

here is edit.php:

 

<?PHP include('dbconnect.php') ?>

<HTML>

<HEAD>

<TITLE>Barry Ottley Motor Co - Quality Used Motors - Stanford-Le-Hope, Essex</TITLE>

</HEAD>



<BODY LINK="#000000" ALINK="#000000" VLINK="#000000">

<CENTER><IMG SRC="logo.jpg"></CENTER>



<CENTER>

<TABLE WIDTH="840" CELLPADDING="0" CELLSPACING="0" BORDER="0">

<TR>

<TD WIDTH="186" valign="top">
<BR>
<CENTER><A HREF="index.html"><IMG SRC="homepage.jpg" alt="Homepage" border="0"></A></CENTER>
<CENTER><A HREF="showroom.php"><IMG SRC="showroom.jpg" alt="Our Online Showroom" border="0"></A></CENTER>
<CENTER><A HREF="location.html"><IMG SRC="ourlocation.jpg" alt="Our location" border="0"></A></CENTER>
<CENTER><A HREF="aboutus.html"><IMG SRC="aboutus.jpg" alt="About Us" border="0"></A></CENTER>
<CENTER><A HREF="contactus.php"><IMG SRC="contactus.jpg" alt="Contact Us" border="0"></A></CENTER>




</TD>

<TD WIDTH="30" valign="top"> </TD>

<TD valign="top">

<FONT SIZE="2" FACE="ARIAL">

<CENTER><A HREF="addcar.html"><IMG SRC="vehicleadd.jpg" border="0"></A><A HREF="showroomconfig.php"><IMG SRC="vehicleedit.jpg" border="0"></A><A HREF="showroomconfig.php"><IMG SRC="vehicledelete.jpg" border="0"></A></CENTER>

<CENTER><B>Update a Vehicle</B></CENTER>
<BR>

<?php

$query1="SELECT cars FROM CarName='$carname', CarTitle='$CarTitle', CarPrice='$carprice', CarMiles='$carmiles', CarDescription='$cardesc'";
mysql_query($query1);
mysql_close();
?>


<form action="editvehicle.php" method="post">
<CENTER>Vehicle Name:</CENTER> 
<CENTER><input type="text" name="CarName" value="<?php echo $carname; ?>"></CENTER>
<br>
<CENTER>Vehicle Type:</CENTER>
<CENTER><input type="text" name="CarTitle" value="<?php echo $cartitle; ?>"></CENTER>
<br>
<CENTER>Vehicle Price:</CENTER>
<CENTER><input type="text" name="CarPrice" value="<?php echo $carprice; ?>"></CENTER>
<br>
<CENTER>Vehicle Mileage:</CENTER>
<CENTER><input type="text" name="CarMiles" value="<?php echo $carprice; ?>"></CENTER>
<br>
<CENTER>Vehicle Description:</CENTER>
<CENTER><textarea name="CarDescription" rows="10" cols="30" value="<?php echo $cardesc; ?>"></textarea></CENTER>
<br>

<CENTER><input type="Submit"></CENTER>

</form>

</TD>


</TR>

</TABLE>


<BR><BR><BR><BR>

<CENTER><FONT FACE="VERDANA" SIZE="1">

This website was designed and is hosted by <A HREF="http://www.IRCDirect.co.uk">IRC Direct Website Design™</A> 2010

</CENTER>
<BR>
<CENTER><A HREF="admin.php">Employee Area</A>

</BODY>

</HTML>

 

That is not even showing me the table details at all.  Im lost :(.

 

There is an "Update" link in each array in showroom.php in which when the user clicks it opens edit.php .

 

They update the form as they wish... then click update and it updates the database and sends them back to showroomedit.php

 

Much help would be appreciated :D!

 

Cheers paul if your out there still :D

Link to comment
Share on other sites

Ok i had another go at the edit form...  getting an $end error though:

 

edit.php

 

<?PHP include('dbconnect.php') ?>

<HTML>

<HEAD>

<TITLE>Barry Ottley Motor Co - Quality Used Motors - Stanford-Le-Hope, Essex</TITLE>

</HEAD>



<BODY LINK="#000000" ALINK="#000000" VLINK="#000000">

<CENTER><IMG SRC="logo.jpg"></CENTER>



<CENTER>

<TABLE WIDTH="840" CELLPADDING="0" CELLSPACING="0" BORDER="0">

<TR>

<TD WIDTH="186" valign="top">
<BR>
<CENTER><A HREF="index.html"><IMG SRC="homepage.jpg" alt="Homepage" border="0"></A></CENTER>
<CENTER><A HREF="showroom.php"><IMG SRC="showroom.jpg" alt="Our Online Showroom" border="0"></A></CENTER>
<CENTER><A HREF="location.html"><IMG SRC="ourlocation.jpg" alt="Our location" border="0"></A></CENTER>
<CENTER><A HREF="aboutus.html"><IMG SRC="aboutus.jpg" alt="About Us" border="0"></A></CENTER>
<CENTER><A HREF="contactus.php"><IMG SRC="contactus.jpg" alt="Contact Us" border="0"></A></CENTER>




</TD>

<TD WIDTH="30" valign="top"> </TD>

<TD valign="top">

<FONT SIZE="2" FACE="ARIAL">

<CENTER><A HREF="addcar.html"><IMG SRC="vehicleadd.jpg" border="0"></A><A HREF="showroomconfig.php"><IMG SRC="vehicleedit.jpg" border="0"></A><A HREF="showroomconfig.php"><IMG SRC="vehicledelete.jpg" border="0"></A></CENTER>

<CENTER><B>Update a Vehicle</B></CENTER>
<BR>

<?php

$query=" SELECT * FROM cars WHERE id='$id'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();

$i=0;
while ($i < $num) {
$carname=mysql_result($result,$i,"CarName");
$cartitle=mysql_result($result,$i,"CarTitle");
$carprice=mysql_result($result,$i,"CarPrice");
$carmiles=mysql_result($result,$i,"CarMiles");
$cardesc=mysql_result($result,$i,"CarDescription");

?>

<form action="showroomedit.php" method="post">
<CENTER>Vehicle Name:</CENTER> 
<CENTER><input type="text" name="CarName" value="<?php echo $carname; ?>"></CENTER>
<br>
<CENTER>Vehicle Type:</CENTER>
<CENTER><input type="text" name="CarTitle" value="<?php echo $cartitle; ?>"></CENTER>
<br>
<CENTER>Vehicle Price:</CENTER>
<CENTER><input type="text" name="CarPrice" value="<?php echo $carprice; ?>"></CENTER>
<br>
<CENTER>Vehicle Mileage:</CENTER>
<CENTER><input type="text" name="CarMiles" value="<?php echo $carmiles; ?>"></CENTER>
<br>
<CENTER>Vehicle Description:</CENTER>
<CENTER><textarea name="CarDescription" rows="10" cols="30" value="<?php echo $cardesc; ?>"></textarea></CENTER>
<br>

<CENTER><input type="Submit"></CENTER>

</form>

</TD>


</TR>

</TABLE>


<BR><BR><BR><BR>

<CENTER><FONT FACE="VERDANA" SIZE="1">

This website was designed and is hosted by <A HREF="http://www.IRCDirect.co.uk">IRC Direct Website Design™</A> 2010

</CENTER>
<BR>
<CENTER><A HREF="admin.php">Employee Area</A>

</BODY>

</HTML>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.