javascript - DELETE query onclick automized -


having slight problem here. i'm trying create admin side function delete faq's, , despite fact got script working, need figure out how automate [where clause] per added question.

to describe it, every question gets posted , has id in database. want delete on id, per question add

delete faq [where faq_id=#]  

my current code:

$sql = "select question, answer faq";           $queryresult = mysql_query($sql) or die (mysql_error());            while ($faqresult = mysql_fetch_array($queryresult)){             $faqquestion = $faqresult['question'];             $faqanswer = $faqresult['answer'];              echo "<p class='faqquestionadmin'>$faqquestion</p>" .              "<p class='faqansweradmin'>$faqanswer</p>" .              "<a class=faqdelete>x</a>";           }           if(mysql_num_rows($queryresult) <= 0) {             echo("<div><p>no questions available</p></div>");           }          mysql_free_result($queryresult);         mysql_close($conn); 

that serves deleting button. thinking function, know how can this? columns in database each question id, question, , answer.

thanks in advance!

if want avoid ajax, put link in anchor tag php file variable in it:

<a href="http://mysiteurl/php/deletefaq.php?id={faqid}">x</a> 

than in deletefaq.php use

$id = $_get['id']; $query = "delete faq faq_id=$id"; 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -