Note that there are some explanatory texts on larger screens.

plurals
  1. POShow phpmyadmin cell in html textbox value
    primarykey
    data
    text
    <p>I have a database in phpmyadmin called <code>fleet hire motors</code>, and in that database is a table called <code>customer</code>. </p> <p>In that table are columns called <code>customerID</code> and <code>Surname</code>. I have already done some coding on one page that lets the user select the <code>customerID</code> to edit the <code>Surname</code>. </p> <p>On the next page I want a textbox. in that textbox, the default value should be what the current <code>Surname</code> is. </p> <p>So, if i was to edit customer with <code>customerID</code> 1 (of which surname is currently <code>Brown</code> and I want to change to <code>Green</code>) the second page would show <code>Surname: [Brown]</code>, where [] encloses a textbox. </p> <p>I currently do not have any code, and would like to keep it primarily php. The first page is called <code>editcustomer.php</code>, and the second is called <code>editcustomer2.php</code>. </p> <p>Any help is appreciated.</p> <p>My current code is:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Edit Customer&lt;/title&gt; &lt;/head&gt;&lt;body&gt; &lt;?php mysql_connect("localhost","username","password") or die(mysql_error()); mysql_select_db("fleet hire motors") or die(mysql_error()); ?&gt; &lt;?php $CustomerID = $_GET["CustomerID"]; $query=mysql_query(" SELECT * FROM customer WHERE CustomerID = '$CustomerID' ") or die(mysql_error()); while ($row = mysql_fetch_array($query)) { b$CustomerID = $row["CustomerID"]; } ?&gt; First Name: &lt;input name="FirstName" type="text" value=" &lt;?php $FirstName = $_GET["CustomerID"]; include 'db.php'; $query=mysql_query(" SELECT FirstName FROM customer WHERE CustomerID = '$CustomerID' ") or die(mysql_error()); ?&gt; "&gt; &lt;br&gt; &lt;input name="submitbtn" type="submit" value="Save"&gt; &lt;input name="resubmitbtn" type="submit" value="Reset"&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Sorry for all the edits, as I am new to stackoverflow and just learning how to do it.</p> <p>I have now updated my coding thanks to a response, but it is still not working. My most current coding is:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Edit Customer&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;?php mysql_connect("localhost","username","password") or die(mysql_error()); mysql_select_db("fleet hire motors") or die(mysql_error()); ?&gt; &lt;?php $CustomerID = $_GET["CustomerID"]; $query=mysql_query(" SELECT * FROM customer WHERE CustomerID = '$CustomerID' ") or die(mysql_error()); $row = mysql_fetch_array($query); if (!$row || !is_array($row)){ $CustomerID = 0; $CustomerFirstName = ''; } else { $CustomerID = $row["CustomerID"]; $CustomerFirstName = $row['FirstName']; } ?&gt; First Name: &lt;input name="FirstName" type="text" value="&lt;?php echo $CustomerFirstName; ? &gt;"&gt; &lt;input name="submitbtn" type="submit" value="Save"&gt; &lt;input name="resubmitbtn" type="submit" value="Reset"&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This does not give me anything in the textbox, and my submit button does not work.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload