Jump to content

Recommended Posts

Hi Guys.

 

I am not sure I am doing this correct but I have this code already.

 

update.php

<html>
<head>
    <title>Untitled Page</title>

<link href="images/CliftonMotors.css" rel="stylesheet" type="text/css">
</head>
<body style="margin:0;">
<TABLE WIDTH=775 height="100%" BORDER=0 CELLPADDING=0 CELLSPACING=0>
<TR>
	<TD height="89" COLSPAN=2>
		<table width="100%"  border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="374"><img src="images/toplogo2.gif" width=374 height=89 alt=""></td>
                <td><TABLE width="401" BORDER=0 CELLPADDING=0 CELLSPACING=0>
                  <TR>
                    <TD COLSPAN=11> <IMG SRC="images/jd_b038_02.gif" WIDTH=401 HEIGHT=40 ALT=""></TD>
                  </TR>
                  <TR>
                    <TD><a href="javascript:;"><IMG SRC="images/btn_home.gif" ALT="" WIDTH=57 HEIGHT=49 border="0"></a></TD>
                    <TD><IMG SRC="images/navspacer.gif" WIDTH=2 HEIGHT=49 ALT=""></TD>
                    <TD><a href="javascript:;"><IMG SRC="images/btn_aboutus.gif" ALT="" WIDTH=57 HEIGHT=49 border="0"></a></TD>
                    <TD><IMG SRC="images/navspacer2.gif" WIDTH=2 HEIGHT=49 ALT=""></TD>
                    <TD><a href="javascript:;"><IMG SRC="images/btn_contact.gif" ALT="" WIDTH=66 HEIGHT=49 border="0"></a></TD>
                    <TD><IMG SRC="images/navspacer3.gif" WIDTH=2 HEIGHT=49 ALT=""></TD>
                    <TD><a href="javascript:;"><IMG SRC="images/btn_products.gif" ALT="" WIDTH=78 HEIGHT=49 border="0"></a></TD>
                    <TD><IMG SRC="images/navspacer4.gif" WIDTH=2 HEIGHT=49 ALT=""></TD>
                    <TD><a href="javascript:;"><IMG SRC="images/btn_support.gif" ALT="" WIDTH=71 HEIGHT=49 border="0"></a></TD>
                    <TD><IMG SRC="images/navspacer5.gif" WIDTH=2 HEIGHT=49 ALT=""></TD>
                    <TD><a href="javascript:;"><IMG SRC="images/btn_news.gif" ALT="" WIDTH=62 HEIGHT=49 border="0"></a></TD>
                  </TR>
                </TABLE></td>
              </tr>
            </table></TD>
</TR>
<TR>
	<TD valign="top" background="images/pixi_1.gif"><table width="100%" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td><TABLE width="553" BORDER=0 CELLPADDING=0 CELLSPACING=0>
             
            </TABLE></td>
          </tr>
          <tr>
            <td height="18" background="images/pixi_grey.gif" style="padding-left:40;padding-top:5;padding-right:35;"><h1>Welcome to Clifton Motors</h1></td>
          </tr>
          <tr>
            <td style="padding-left:40;padding-top:25; padding-right:35;padding-bottom:25;">


<?
//connect to mysql
//change user and password to your mySQL name and password
mysql_connect("localhost","root","");

//select which database you want to edit
mysql_select_db("car"); 

//select the table
$result = mysql_query("select * from car");

//grab all the content
while($r=mysql_fetch_array($result))
{	
   //the format is $variable = $r["nameofmysqlcolumn"];
   //modify these to match your mysql table columns
  
   $price=$r["price"];
   $description=$r["description"];
   $photo=$r["photo"];
   $id=$r["id"];
  
   //display the row
   echo "$price";

   echo	"$description";

   echo '<a href="updater.php?id=' . $id . '"> click here to update</a>';



}
?>

                
          </td>
          </tr>
      </table></TD>

</TR>
<TR>
	<TD background="images/pixi_2.gif" height="37" COLSPAN=2 style="padding-left:40;">© Keith Coatsworth. </TD>
  </TR>
<TR>
	<TD height="7" COLSPAN=2 background="images/pixi_grey.gif"><IMG SRC="images/spacer.gif" WIDTH=775 HEIGHT=7 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</html>

 

updater.php

 

<?

$id = $_GET['id'];

mysql_connect("localhost","root","");

mysql_select_db("car"); 

$result = mysql_query("select * from car WHERE id = '$id'") or DIE(mysql_error());

mysql_query("UPDATE car SET status = 'Sold'
WHERE id = $id'");

?>

 

I have run this, no errors, I think i need to put something in, but I am unsure what.  But it does not update the field to sold.

Link to comment
https://forums.phpfreaks.com/topic/51096-solved-updating-a-mysql-field/
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.