Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Button instead of Link question...
Old 02-23-2009, 05:30 PM Button instead of Link question...
Average Talker

Posts: 15
Name: Declan Dowling
Trades: 0
Hello again,

Before I start I'd like to apologize if I keep asking really noobish questions, but I'm just getting back into coding after a well deserved and lengthy break so...

I'm using a while loop to show all of my records from the database, and after each record I want the option to delete it, buy via a button instead of a link.

I know I could delete it using a link if i went: ?del_id=$record->id
But I've forgotten how to do this with a button.

Please don't laugh at me.


PS: I know that I'll kick myself when someone posts it here.

Last edited by Declan; 02-23-2009 at 05:31 PM.. Reason: I'm a noob
Declan is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-23-2009, 05:53 PM Re: Button instead of Link question...
vangogh's Avatar
Post Impressionist

Latest Blog Post:
Why Responsive Design?
Posts: 10,815
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
Assuming the link works like you want, you can always create an image for the button and wrap the link around it.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 02-23-2009, 06:06 PM Re: Button instead of Link question...
Average Talker

Posts: 15
Name: Declan Dowling
Trades: 0
Thanks for the reply, and that could be a solution.
But I'm sure that I've done this before. It was just a long time ago.
Plus, I have used buttons throughout my site so an image would look out of place.
Declan is offline
Reply With Quote
View Public Profile
 
Old 02-23-2009, 06:17 PM Re: Button instead of Link question...
vangogh's Avatar
Post Impressionist

Latest Blog Post:
Why Responsive Design?
Posts: 10,815
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
If you're going to use a standard html form button then usually you'll send the button to a javascript function. You can then call the database from the javascript using an Ajax call.

In the button you'd have something like onclick="name-of-your-function"
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 02-23-2009, 07:40 PM Re: Button instead of Link question...
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
wrap the link around a <button> element or vice versa
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 02-23-2009, 10:02 PM Re: Button instead of Link question...
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
Quote:
Originally Posted by chrishirst View Post
wrap the link around a <button> element or vice versa
<button onclick="window.location='?del_id=XX';">DELETE</button>
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 02-23-2009, 11:50 PM Re: Button instead of Link question...
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Or make a small form only containing a button, like so.
Code:
<form method="post" action="delete_script.php?id=$recordID">
<input type="hidden" name="recordID" value="$recordID">
<input type="submit" value="Delete record" />
</form>
I've put the record id in both the action and as a hidden variabe, just to show both possabilities, you would normally only use one of them.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 02-24-2009, 02:33 PM Re: Button instead of Link question...
Average Talker

Posts: 15
Name: Declan Dowling
Trades: 0
Thanks alot everyone, helped me out!
I'm gonna go with the link inside the button method suggested by chrishirst and mgraphic.
Declan is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Button instead of Link question...
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.26757 seconds with 12 queries