WeLoveCSS Logo
Home Profile Members Search Rules Help New Posts



WeLoveCSS > PROGRAMMING LANGUAGES > Scripting and Server Side > undefined index id php issue

Reply
  Thread Tools Display Modes
Old 11th October 15, 09:22 AM   #1
ianhaney
WLC Lover
 
Join Date: Jun 2012
Posts: 78
Default 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

PHP Code:
<?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>
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

PHP Code:
$id ''
Thank you in advance

Ian
ianhaney is offline   Reply With Quote
Old 11th October 15, 09:55 PM   #2
meesa
WLC Mod
 
meesa's Avatar
 
Join Date: Jul 2009
Location: Milky Way Galaxy
Posts: 3,710
Default Re: undefined index id php issue

I would assume this is the culprit

Code:
="<?php echo $row["id"] ?>
Check to ensure that your query is giving back an ID index. print_r is an easy way to dump the array to see what it has in it.
__________________
Praise be to the Lord God for the ability to learn, the capability to analyze, and the time to help users on this forum.
meesa is offline   Reply With Quote
Reply


Thread Tools
Display Modes
Linear Mode Linear Mode

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:02 AM.



Home | Advertise | Contact Us | Top
Home | Advertise | Contact Us | Top

Copyrightę 2006 WeLoveCSS.com. All Rights Reserved.
Powered by vBulletin Version 3.8.4 Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.