0

I wonder why it doesn't want to retrieve the P_id information when I press hapus/delete button. It suppose to bypass P_id value so that I know which to delete.

The url remains empty: http://localhost/innovation/script_shop/hapus.php?P_id=

<?php

    $result = mysql_query("SELECT * FROM stock")
    or die(mysql_error());

    echo "<table border=1>";
    echo "<tr>";
    echo "<th>Produk</th><th>Jumlah</th><th>Tanggal</th>";
    echo "</tr>";


    $i=0;
    while($row = mysql_fetch_array( $result )) {    
    $result2=($i%2)?'#DFA09D':'white';

    echo "<tr bgcolor='$result2'>";
    echo "<td>";
    echo $row['Produk'];
    echo "</td>";
    echo "<td>";
    echo $row['Jumlah'].'<br/>';
    echo "</td>";
    echo "<td>";
    echo $row['Tanggal'];
    echo "</td>";
    echo "<td>";
    echo "Edit";
    echo "</td>";
    echo "<td>";
    echo "<a href='hapus.php?P_id='".$row['P_id'].">hapus</a>";
    echo "</td>";
    echo "</tr>";

    $i++;
    } 
3
Contributors
6
Replies
7
Views
4 Years
Discussion Span
Last Post by simplypixie
0

@davy_yg

I wonder why it doesn't want to retrieve the P_id information when I press hapus/delete button. It suppose to bypass P_id value so that I know which to delete.

What are you talking?

I don't see any function that you are trying to retrieve from the database nor a button that delete a valve.

All I see is 2 query. One is to SELECT and the other to Fetch an ID.

You didn't how it works or how it bypass a valve.

0

hapus means delete. Yes, there is column in the database called P_id it's primary key and auto increment. P_id means product id.

Edited by davy_yg

0

If that is definitely the correct column name then your formatting is incorrect for the echo and you are missing a ' befoe the closing > of the href.

I always find it best / easiest to keep HTML and PHP separate so can you try this and see if it works

while($row = mysql_fetch_array( $result )) {    
    $result2=($i%2)?'#DFA09D':'white';
}
    <tr bgcolor="<?php echo $result2; ?>";
    <td><?php echo $row['Produk']; ?></td>
    <td><?php echo $row['Jumlah']; ?></td>
    <td><?php echo $row['Tanggal']; ?></td>
    <td>Edit</td>
    <td><a href="hapus.php?P_id=<?php echo $row['P_id']; ?>">hapus</a></td>
    </tr>
<?php
    $i++;
?>
0

Parse error: syntax error, unexpected '<' in C:\xampp\htdocs\Innovation\script_shop\stock3.php on line 102

line 102:<tr bgcolor="<?php echo $result2; ?>">

Edited by davy_yg

2

Sorry to be rude, but surely you can work out that there is a missing closing tag and don't need help with that???

I made a typo:

<tr bgcolor="<?php echo $result2; ?>">
Votes + Comments
You're not rude. You'll absolute right!
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.