/    Sign up×
Community /Pin to ProfileBookmark

undefined index id php issue

Hi

I am building an admin backend script where data can be added, updated and deleted and just working on the view customers coding at the mo, it all works and I have got the data displayed from the database but am trying to add edit and delete links but am getting the following errors

Notice: Undefined index: id in /home/sites/it-doneright.co.uk/public_html/admin/view-customers.php on line 78
“>Edit

Notice: Undefined index: id in /home/sites/it-doneright.co.uk/public_html/admin/view-customers.php on line 79
” onClick=”return confirm(‘.”‘Are you sure you want to delete this record?’);”.'”>Delete

The coding I have is below

[code=php]
<?php

$con= mysqli_connect(“localhost”, “username”, “password”, “dbname”);
if(!$con)
{
die(‘not connected’);
}
$con= mysqli_query($con, “SELECT plans_name, machine1, machine2, machine3, machine4, machine5, customer_name, customer_email, customer_phone, DATE_FORMAT(date_purchased_plan, ‘%d/%m/%Y’) AS date_purchased_plan from plans”);

?>

<div>

<td>Customers</td>
<table>
<th>Support Plan</th>
<th>Machine 1</th>
<th>Machine 2</th>
<th>Machine 3</th>
<th>Machine 4</th>
<th>Machine 5</th>
<th>Customer Name</th>
<th>Customer Email</th>
<th>Customer Phone</th>
<th>Plan Purchase Date</th>
<th colspan=”2″>Actions</th>

</tr>

<?php

while($row= mysqli_fetch_array($con))
{
?>
<tr>
<td><?php echo $row[‘plans_name’]; ?></td>
<td><?php echo $row[‘machine1’]; ?></td>
<td><?php echo $row[‘machine2’]; ?></td>
<td><?php echo $row[‘machine3’] ;?></td>
<td><?php echo $row[‘machine4’] ;?></td>
<td><?php echo $row[‘machine5’] ;?></td>
<td><?php echo $row[‘customer_name’] ;?></td>
<td><?php echo $row[‘customer_email’] ;?></td>
<td><?php echo $row[‘customer_phone’] ;?></td>
<td><?php echo $row[‘date_purchased_plan’];?></td>
<td><a href=”edit-customer.php?id=”<?php echo $row[“id”] ?>”>Edit</a></td>
<td><a href=”delete.php?id=”<?php echo $row[“id”] ?>” onClick=”return confirm(‘.”‘Are you sure you want to delete this record?’);”.'”>Delete</a></td>
</tr>
<?php
}
?>
</table>
</div>
[/code]

Just seeing if someone can help me and see where I am going wrong

I have tried googling it and added in following coding above the SELECT query but didn’t seem to work so removed it again

[code=php]
$id = ”;
[/code]

Thank you in advance

Ian

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogOct 11.2015 — You do not select a column named "id" in your DB query, so when you try to reference [b]$row['id'][/b], there is no such index/key in that array, thus the warning message.
Copy linkTweet thisAlerts:
@ianhaneyauthorOct 11.2015 — Hi NogDog

Thank you for the reply, appreciate it

I got the id issue sorted by using another script but it has stopped my select and extra fields displaying when a specific option value is selected

Below is the pastebin link to my records.php coding

http://pastebin.com/kFk7XtuH

I can't see why it has stopped working
Copy linkTweet thisAlerts:
@ianhaneyauthorOct 11.2015 — Sorry is my fault I got it sorted now, I forgot to add id to the form tag
×

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.6,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...