/    Sign up×
Community /Pin to ProfileBookmark

trouble populating form with mysql data

Hi I am trying to make a edit page but having an issue with populating the form with the mysql data

I have the following code but am getting Notice: Undefined variable: id in /home/sites/it-doneright.co.uk/public_html/admin/repairs-tracking/edit-repair-tracking.php on line 52

[CODE]
<?php

$servername = “localhost”;
$username = “”;
$password = “”;
$dbname = “”;

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die(“Connection failed: ” . $conn->connect_error);
}

$sql = “SELECT * FROM repairs WHERE id=’$id'”;
//$result = mysqli_query($sql);
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_array($result);

?>

<form action=”update-admin-repair-tracking.php” method=”post”>

<label>Repair ID</label>
<input name=”id” value=”<?php echo $row[‘id’]; ?>”>

<label>Customer Name</label>
<input type=”text” name=”customer_name” value=”<?php echo $row[‘$customer_name’]; ?>”>

<label>Customer Email</label>
<input type=”text” name=”customer_email” value=”<?php echo $row[‘customer_email’]; ?>”>

<label>Customer Phone</label>
<input type=”text” name=”customer_phone” value=”<?php echo $row[‘customer_phone’]; ?>”>

<label>Computer Make</label>
<input type=”text” name=”computer_make” value=”<?php echo $row[‘computer_make’]; ?>”>

<label>Computer Model</label>
<input type=”text” name=”computer_model” value=”<?php echo $row[‘computer_model’]; ?>”>

<label for=”technician”>Technician:</label>
<select name=”technician” id=”technician”>
<option value=”Not Assigned”>Not Assigned</option>
<option value=”Phil Roskams”>Phil Roskams</option>
<option value=”Ian Haney”>Ian Haney</option>
</select>

<label for=”status”>Status:</label>
<select name=”status” id=”status”>
<option value=”Not Started”>Not Started</option>
<option value=”In Queue”>In Queue</option>
<option value=”On Bench / Working”>On Bench / Working</option>
<option value=”Awaiting Parts”>Awaiting Parts</option>
<option value=”Awaiting Customer”>Awaiting Customer</option>
<option value=”Completed”>Completed</option>
</select>

<label>Expected Repair Date</label>
<input type=”date” name=”exrdate” value=”<?php echo $row[‘exrdate’]; ?>”>

<label>Expected Repair Time</label>
<input type=”time” name=”exrtime” value=”<?php echo $row[‘exrtime’]; ?>”>

<label>Expected Start Date</label>
<input type=”date” name=”exstdate” value=”<?php echo $row[‘exstdate’]; ?>”>

<label>Expected Start Time</label>
<input type=”time” name=”exstime” value=”<?php echo $row[‘exstime’]; ?>”>

<label for=”deltype”>Delivery Type:</label>
<select name=”deltype” id=”deltype”>
<option value=”Self Pickup”>Self Pickup</option>
<option value=”Deliver to Customer”>Delivery to Customer</option>
</select>

<label for=”comments”>Comments:</label>
<br>
<textarea name=”comments” cols=”50″ rows=”3″ id=”comments”><?php echo $row[‘comments’]; ?></textarea>

<input type=”submit” VALUE=”Update Repair Tracking” NAME=”Submit”>

</form>
[/CODE]

Thank you in advance

Ian

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmOct 31.2015 — Ok - walk with me here. You have a script that begins right off the bat with a db connection, followed by a query using a variable $id and then you build your output html with the results. Just what is $id at that point?

PS - I don't know where line 52 is since you didn't bother to point it out. And the only place I found $id was at the beginning as I just described.
×

Success!

Help @ianhaney spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...