Rizla Posted April 5, 2007 Share Posted April 5, 2007 Hello, i'm making this guestbook admin script for a client and i'm using an ajaxscript that loads external files into divs on my pages. when a link is pressed it includes the file to the requested div like so <a href="javascript:ajaxpage('example.php','exaple_div');">[/url] then we would need a div <div id="example_div></div> to represent the requested page. now in order to make the edit function, you need to send the id of the db entry in a $_GET right? so this is what i tried: gbbeheer.php just retrieves data from my db and shows it and then at the end of every displayed entry there is an edit and delete button (link) located the lower part of gbbeheer.php. Now i wonder if this would work or am i completely doing it wrong??? atm i'm getting this error: "this is an errorQuery was empty" when i press the edit button. gbbeheer.php: <?php include("../config.php"); ?> <div class="toevoegendiv"> <table width="599" border="0" cellpadding="4" cellspacing="2"> <tr> <td colspan="8" valign="top" class="container"><p class="title">Welkom op je beheer pagina voor jouw gastenboek.</p> </td> </tr> <tr> <td colspan="8"> <div id="exec_div"></div> </td> </tr> <tr> <td width="20" class="menu"><p class="formtext">N°</p></td> <td width="224" class="menu"><p class="formtext">Naam</p></td> <td width="224" class="menu"><p class="formtext">Datum</p></td> <td width="450" class="menu"><p class="formtext">Website</p></td> <td width="450" class="menu"><p class="formtext">Bericht</p></td> <td width="450" class="menu"><p class="formtext">ip</p></td> <td width="224" class="menu"><p class="formtext">bewerken</p></td> <td width="224" class="menu"><p class="formtext">verwijderen</p></td> </tr> <?php $query = "SELECT * FROM guestbook ORDER BY ID DESC"; $result = mysql_query($query)or die(mysql_error()); while($r=mysql_fetch_array($result)) { extract($r); ?> <tr> <td class="menu"><?= $id ?></td> <td class="menu"><?= $author ?></td> <td class="menu"><?= $date ?></td> <td class="menu"><a href="<?= $website ?>" target="_blank"><?= $website ?></a></td> <td class="menu"><?= $bericht ?></td> <td class="menu"><?= $ip ?></td> <td class="btn"><a href="javascript:ajaxpage('gbentry.php?action=edit&id=$id','exec_div');">bewerken</a></td> <td class="btn"><a href="javascript:ajaxpage('gbentry.php?action=delete&id=$id','exec_div');">bewerken</a></td> </tr> <?php } ?> <tr> <td colspan="8" class="container"> </td> </tr> </table> </div> ------------------------------------------------------------------------------------------- and then gbentry.php: <?php include("../config.php"); ?> <div class="toevoegendiv"> <table width="599" border="0" cellpadding="4" cellspacing="2"> <tr> <td colspan="8" valign="top" class="container"><p class="title">Welkom op je beheer pagina voor jouw gastenboek.</p> </td> </tr> <tr> <td colspan="8"> <div id="exec_div"></div> </td> </tr> <tr> <td width="20" class="menu"><p class="formtext">N°</p></td> <td width="224" class="menu"><p class="formtext">Naam</p></td> <td width="224" class="menu"><p class="formtext">Datum</p></td> <td width="450" class="menu"><p class="formtext">Website</p></td> <td width="450" class="menu"><p class="formtext">Bericht</p></td> <td width="450" class="menu"><p class="formtext">ip</p></td> <td width="224" class="menu"><p class="formtext">bewerken</p></td> <td width="224" class="menu"><p class="formtext">verwijderen</p></td> </tr> <?php $query = "SELECT * FROM guestbook ORDER BY ID DESC"; $result = mysql_query($query)or die(mysql_error()); while($r=mysql_fetch_array($result)) { extract($r); ?> <tr> <td class="menu"><?= $id ?></td> <td class="menu"><?= $author ?></td> <td class="menu"><?= $date ?></td> <td class="menu"><a href="<?= $website ?>" target="_blank"><?= $website ?></a></td> <td class="menu"><?= $bericht ?></td> <td class="menu"><?= $ip ?></td> <td class="btn"><a href="javascript:ajaxpage('gbentry.php?action=edit&id=$id','exec_div');">bewerken</a></td> <td class="btn"><a href="javascript:ajaxpage('gbentry.php?action=delete&id=$id','exec_div');">bewerken</a></td> </tr> <?php } ?> <tr> <td colspan="8" class="container"> </td> </tr> </table> </div> ------------------------------------------------------------------------------------------- thanks in advance Wink greets Rizla Quote Link to comment Share on other sites More sharing options...
mainewoods Posted April 5, 2007 Share Posted April 5, 2007 when you do these 2 statements, you are not in php mode, you are in html mode: <td class="btn"><a href="javascript:ajaxpage('gbentry.php?action=edit&id=$id','exec_div');">bewerken</a></td> <td class="btn"><a href="javascript:ajaxpage('gbentry.php?action=delete&id=$id','exec_div');">bewerken</a></td> --so therefore $id is printed as a string, not it's value. Instead use: <td class="btn"><a href="javascript:ajaxpage('gbentry.php?action=edit&id=<?= $id ?>','exec_div');">bewerken</a></td> <td class="btn"><a href="javascript:ajaxpage('gbentry.php?action=delete&id=<?= $id ?>','exec_div');">bewerken</a></td> Quote Link to comment Share on other sites More sharing options...
Rizla Posted April 5, 2007 Author Share Posted April 5, 2007 Thanks dude it works now there still remain some issue's but i'll figure out btw i had to change my code on gbentry.php needed to use a switch to catch the actions (edit,delete) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.