Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old December 9th, 2003, 05:44 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
adding delete and edit buttons to data gathered from MySql

just like in phpadmin
here is my code
Code:
<?PHP
$db = mysql_connect("localhost","root","") or die("Problem connecting");
mysql_select_db("VC") or die("Problem selecting database");
$query = "SELECT * FROM inventory ORDER BY prod_code";
$result = mysql_query($query) or die ("Query failed");
$numofrows = mysql_num_rows($result);

echo "<TABLE BORDER="0">n";
echo "<TR bgcolor="lightblue"><TD>ID</TD><TD>Name</TD>
<TD>Description</TD><TD>Retail Price</TD><TD>Wholesale Price</TD><TD>Quanity</TD><TD></TD><TD></TD></TR>n";
for($i = 0; $i < $numofrows; $i++) {
    $row = mysql_fetch_array($result); 
    if($i % 2) {
        echo "<TR bgcolor="lightgrey">n";
    } else { 
        echo "<TR bgcolor="white">n";
    }
    echo "<TD>".$row['prod_code']."</TD><TD>".$row['prod_name']."</TD><TD>".$row['prod_description']."</TD>
<TD>".$row['price_retail']."</TD><TD>".$row['price_whole']."</TD><TD>".$row['quanity']."</TD><TD></TD><TD></TD>n";
    echo "</TR>n";
	}
echo "</TABLE>n";
?> 


i added two columns for the edit and delete buttons

i see that you have to use the "DELETE FROM table WHERE field = 'xxx'" in order to accomplish the deletetion of a row of data. now how do i tell it to delete the row that the delete button exists on? is it something like
DELETE FROM inventory WHERE prod_id = '$row['prod_id']'
i cant get this right for nothing
thanks in advance

Reply With Quote
  #2  
Old December 9th, 2003, 11:36 PM
postalcow postalcow is offline
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Ford CIty, PA USA
Posts: 1,267 postalcow User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via Yahoo to postalcow
RE: adding delete and edit buttons to data gathered from MySql

I pulled this code from one of my applications. I just add the links to html in the loop like this
php Code:
Original - php Code
  1.  
  2.     <td width="6%"><b><form method=post action="einvoice/edit_customer_info.php"><input type="image" src="edit.gif" border="0"><input type="hidden" name="passed_cus_id" value="$id_num"></b></td></form>


This one uses images for buttons like phpmyadmin. This should give you an idea of how it is done. I pass the ID in a hidden field.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > adding delete and edit buttons to data gathered from MySql


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway