| | |
can we use mysql(DELETE...) query in the same page while having anchor tags?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: May 2008
Posts: 67
Reputation:
Solved Threads: 3
Hi all,
Instead of passing the variables to the other page and coding mysql queries there.. Is it possible that we can use the mysql(DELETE...) query within the anchor tags in the same page?
<a href >... to delete a particular row in mysql table?
Like having a link called delete and by clicking on that , a particular row must be deleted in the table.
eg:- <a href = " .... some mysql query....">DELETE</a>
(or)
eg:- <a href="<?php //delete this row ?>">delete</a>
(or)
eg:-
Instead of passing the variables to the other page and coding mysql queries there.. Is it possible that we can use the mysql(DELETE...) query in the same page?
I was wondering if there is some possibility like this in PHP .
Please let me know if there are any such methods .
Thankyou all in Advance.
Instead of passing the variables to the other page and coding mysql queries there.. Is it possible that we can use the mysql(DELETE...) query within the anchor tags in the same page?
<a href >... to delete a particular row in mysql table?
Like having a link called delete and by clicking on that , a particular row must be deleted in the table.
eg:- <a href = " .... some mysql query....">DELETE</a>
(or)
eg:- <a href="<?php //delete this row ?>">delete</a>
(or)
eg:-
php Syntax (Toggle Plain Text)
<?php //db connections.. $result = mysql_query("SELECT commentid FROM comments") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { ?> <a href="<?php //delete this row ?>">delete</a> <?php } ?>
Instead of passing the variables to the other page and coding mysql queries there.. Is it possible that we can use the mysql(DELETE...) query in the same page?
I was wondering if there is some possibility like this in PHP .
Please let me know if there are any such methods .
Thankyou all in Advance.
Kavitha
I Love My Indonesia.
I Love My Indonesia.
•
•
•
•
php Syntax (Toggle Plain Text)
<?php //db connections.. $result = mysql_query("SELECT commentid FROM comments") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { ?> <a href="<?php //delete this row ?>">delete</a> <?php } ?>
Instead of passing the variables to the other page and coding mysql queries there.. Is it possible that we can use the mysql(DELETE...) query in the same page?
I was wondering if there is some possibility like this in PHP .
Please let me know if there are any such methods .
Thankyou all in Advance.
(this is your page,e.g. sample.php)
php Syntax (Toggle Plain Text)
<?php //db connections.. $result = mysql_query("SELECT commentid FROM comments") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { ?> <a href="sample.php?delete_id=<?=$row['id']?>">delete</a> <?php } ?>
put your delete statement above...
(sample.php)
php Syntax (Toggle Plain Text)
//db connections.. if ($_GET['delete_id']!="") { //delete statement goes here.... } $result = mysql_query("SELECT commentid FROM comments") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { ?> <a href="sample.php?delete_id=<?=$row['id']?>">delete</a> <?php } ?>
•
•
Join Date: May 2008
Posts: 67
Reputation:
Solved Threads: 3
Thankyou for your time ryan_vietnow
Passing it to the next page is what we are doing here too ....other than this method..
cant we simply run the query in the same page where the anchor tag is present instead of passing it over to next page?
Passing it to the next page is what we are doing here too ....other than this method..
cant we simply run the query in the same page where the anchor tag is present instead of passing it over to next page?
Last edited by Kavitha Butchi; Jul 8th, 2008 at 12:24 am.
Kavitha
I Love My Indonesia.
I Love My Indonesia.
•
•
Join Date: May 2008
Posts: 67
Reputation:
Solved Threads: 3
like
something like that which works..where everything is coded in a single page rather than passing it over to the other page.
php Syntax (Toggle Plain Text)
//...database connections... <a href=mysql_query("DELETE FROM example WHERE age='15'")>delete</a>
Kavitha
I Love My Indonesia.
I Love My Indonesia.
•
•
•
•
like
something like that which works..where everything is coded in a single page rather than passing it over to the other page.php Syntax (Toggle Plain Text)
//...database connections... <a href=mysql_query("DELETE FROM example WHERE age='15'")>delete</a>
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
Hello kavitha try this...
And your a href must be in form tag...
This is working finely...try this...
Thanks.
Shanti
PHP Syntax (Toggle Plain Text)
<? /...database connections... if(!empty($_GET['delid'])){ mysql_query("delete from category WHERE id='".$_GET['delid']."'"); if(!empty($_GET['start'])) { header("location:add_subcategory.php?msg=del&start=".$_GET['start'].""); }else{ header("location:samepage.php?msg=del"); } } ?> //This is in your designing table... <td height="22" align="center" ><a href="javascript:del('<? echo $frow['id'];?>')">Delete</a> </td> //and this can be anyware in your page <script language="javascript"> var d = document.frmmngmall; function del(x) { if(confirm("You want to delete this record")) { d.action="samepage.php?delid="+x; d.submit(); } return; } </script>
And your a href must be in form tag...
This is working finely...try this...
Thanks.
Shanti
Hello kavitha try this...
And your a href must be in form tag...
This is working finely...try this...
Thanks.
Shanti
PHP Syntax (Toggle Plain Text)
<? /...database connections... if(!empty($_GET['delid'])){ mysql_query("delete from category WHERE id='".$_GET['delid']."'"); header("location:samepage.php?msg=del"); } ?> //This is in your designing table... <td height="22" align="center" ><a href="javascript:del('<? echo $frow['id'];?>')">Delete</a> </td> //and this can be anyware in your page <script language="javascript"> var d = document.frmmngmall; function del(x) { if(confirm("You want to delete this record")) { d.action="samepage.php?delid="+x; d.submit(); } return; } </script> <? /...database connections... if(!empty($_GET['delid'])){ mysql_query("delete from category WHERE id='".$_GET['delid']."'"); if(!empty($_GET['start'])) { header("location:add_subcategory.php?msg=del&start=".$_GET['start'].""); }else{ header("location:samepage.php?msg=del"); } } ?> //This is in your designing table... <td height="22" align="center" ><a href="javascript<b></b>:del('<? echo $frow['id'];?>')">Delete</a> </td> //and this can be anyware in your page <script language="javascript"> var d = document.frmmngmall; function del(x) { if(confirm("You want to delete this record")) { d.action="samepage.php?delid="+x; d.submit(); } return; } </script>
And your a href must be in form tag...
This is working finely...try this...
Thanks.
Shanti
•
•
Join Date: May 2008
Posts: 67
Reputation:
Solved Threads: 3
Hello nav33n,
thank you fr the response.
While googling fr this info I found out these broken strings..dont exactly if this is relevant or not.. thought I could ask it here...
You are not an employee of <br /> <b>Warning</b>: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Access denied for user ...
So I thought there might be something like this function.mysql-query....
Please Let me know if nothing as such exists.
complete search result:
<br /> <b>Warning</b>: mysql_connect() [<a href='function.mysql ...
11) You are not an employee of <br /> <b>Warning</b>: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Access denied for user ...
www.myrandomblogs.org/register.php - 25k - Cached - Similar pages - Note this
googled with search term as : <a href=function mysql(delete from
thank you fr the response.
While googling fr this info I found out these broken strings..dont exactly if this is relevant or not.. thought I could ask it here...
You are not an employee of <br /> <b>Warning</b>: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Access denied for user ...
So I thought there might be something like this function.mysql-query....
Please Let me know if nothing as such exists.
complete search result:
<br /> <b>Warning</b>: mysql_connect() [<a href='function.mysql ...
11) You are not an employee of <br /> <b>Warning</b>: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Access denied for user ...
www.myrandomblogs.org/register.php - 25k - Cached - Similar pages - Note this
googled with search term as : <a href=function mysql(delete from
Kavitha
I Love My Indonesia.
I Love My Indonesia.
Re: can we use mysql(DELETE...) query in the same page while having anchor tags?
1
#10 Jul 8th, 2008
mysql_connect error is because the user gave wrong credentials to connect to the database.
Its not possible to call a php function or a mysql query with "onclick" event. As others have mentioned already, you can use ajax or pass the id of the record in the anchor tag and then do relevant operation.
Its not possible to call a php function or a mysql query with "onclick" event. As others have mentioned already, you can use ajax or pass the id of the record in the anchor tag and then do relevant operation.
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
Other Threads in the PHP Forum
- Previous Thread: Not all rows are being displayed in mysql_fetch_row function
- Next Thread: heredoc Problem
| Thread Tools | Search this Thread |
.htaccess action ajax apache api array auto beginner binary bounce broken cakephp checkbox class cms code cron curl database date display dynamic echo email error errorlog file files folder form format forms function functions google href htaccess html image include insert integration interactive ip java javascript joomla limit link login loop mail malfunctioning masterthesis menu mlm mod_rewrite multiple mysql nodes oop paypal pdf php popup problem query radio ram random recursion reference regex remote return script search server sessions sms soap source space sql syntax system table tutorial unset update upload url validation validator variable video web websitecontactform xml youtube






