How to display data that comes from users from a select form, into a div in the same page where is placed the select form? After is selected the category and subcategory, into the div named "Objects" should appear the names of specific objects retrieve from Database. The layout of the html page is: and the php code i used to retrieve data from Database is : <?php include("dbinfo.php"); $connection = mysql_connect($server,$username,$password); if (!$connection) { die('Not connected : ' . mysql_error()); } $db_selected = mysql_select_db($database, $connection); if (!$db_selected) { die ('Can\'t use db : ' . mysql_error()); } $result1=mysql_query("Select idg from Group where category='$_POST[category]' and subcategory='$_POST[subcategory]'") or die(mysql_error()); $row1 = mysql_fetch_array($result1); $classification = $row1['idg']; $result2=mysql_query("Select oname from Object where classification='$classification'") or die(mysql_error()); <? }else{ while($row2 = mysql_fetch_array($result2)){ echo $row2['oname']; echo "<br/>"; } } mysql_close($connection); ?> PHP:
I've no idea what you're trying to do - display data from the database like the form example in the picture or get data from the form and add it to the database?
I know that, but I said that the div is placed in the same page where is the form selected(also the logo, menus,etc), and I don't want to echo in a different blank page,
Can you post some code? Right now I'm guessing that your form is called one thing and the action in your form points elsewhere. If you make the form point to itself you can display the data easily that way. If you do post code please enclose it using the CODE tags to preserve formatting.
lol not the simplest solution AJAX can be a headache - just seen your topic on the other forums - I'm there as well.
Ajax is simple and people who make it complicate Just learn it from beginning and its simple Problem is if someone donot start from begining he will allways say its complicated Sorry but nothing is complicated Regards Alex
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Administration Page</title> <link rel="stylesheet" type="text/css" href="faqet.css"> <link rel="stylesheet" type="text/css" href="menut.css"> <link rel="shortcut icon" href="favicon.ico" /> </head> <body style="background-color: #000000;" onunload="GUnload()"> <center> <img src="logo8.gif" width="84%" height="200" style="margin-top: -1.3%; margin-bottom: -0.7%"> <table width="85%" height="45" border="0" cellpadding="0" cellspacing="0" style="margin-left: 8%; margin-right: 8%"> <tr><td><ul id="nav"> <li><strong><a href="http://clicktirana.com/Faqja2/Faqja2.htm"><span id="me">Clicktirana</span></a> </strong> </li> <li><strong><a href=""><span id="men">Map</span></a></strong> <ul> <li class="menu"><a href="http://clicktirana.com/adm" style="background-color: #000000 " >Add object</a></li> <li class="menu" ><a href="http://clicktirana.com/adm/update_object.html" style="background-color: #000000 " >Update object</a></li> <li class="menu" ><a href="http://clicktirana.com/adm/delete_object.html" style="background-color: #000000 " >Delete object</a></li> </ul> </li> <li><strong><a href=""><span id="g">Gallery</span></a></strong> <ul> <li class="menu"><a href="http://clicktirana.com/adm" style="background-color: #000000 " >Add photo</a></li> <li class="menu" ><a href="http://clicktirana.com/adm" style="background-color: #000000 " >Update photo</a></li> <li class="menu" ><a href="http://clicktirana.com/adm" style="background-color: #000000 " >Delete photo</a></li> </ul> </li> <li><strong><a href=""><span id="e">Events</span></a></strong> <ul> <li class="menu"><a href="http://clicktirana.com/adm" style="background-color: #000000 " >Add event</a></li> <li class="menu" ><a href="http://clicktirana.com/adm" style="background-color: #000000 " >Update event</a></li> <li class="menu" ><a href="http://clicktirana.com/adm" style="background-color: #000000 " >Delete event</a></li> </ul> </li> <li><strong><a href="http://clicktirana.com/Forum/forum.html"><span id="f">Users</span></a></strong></li> </u> </td></tr></table> </center> <!-- Delete form --> <table width="84%" b background="2323452136_45611f9411.jpg" height="200" cellpadding="0" cellspacing="0" style="margin-left: 8%" > <FORM ACTION="show.php" METHOD=POST> <tr> <td width="51%" height="46"> <div align="center"><span class="style9 style11"><b>Choose category & subcategory:</b></span><br/> </div></td> <td width="49%"><div align="center"><span class="style9 style11"><b>Objects:</b></span><br/> </div></td></tr> <tr> <td valign="top" height="258"><div align="center"> <p> <select name="category" id="category" autocomplete="off"> <option value="-1">-------- Select one category -------</option> <option value="Institucione Shteterore">Institucione Shteterore</option> <option value="Institucione Kulturore,Fetare dhe Sportive">Institucione Kulturore,Fetare dhe Sportive</option> <option value="Institucione Financiare">Institucione Financiare</option> <option value="Hoteleri-Turizem">Hoteleri-Turizem</option> <option value="Institucione Arsimore">Institucione Arsimore</option> <option value="Institucione Shendetsore">Institucione Shendetsore</option> </select> </p> <p> <select name="subcategory" id="subcategory" autocomplete="off"> <option value="-1">--- Select one subcategory ---</option> <option value="Institucione Qeveritare">Institucione Qeveritare</option> <option value="Organet e Drejtesise">Organet e Drejtesise</option> <option value="Ambasada">Ambasada</option> <option value="Drejtori">Drejtori</option> <option value="Institucione Nderkombetare">Institucione Nderkombetare</option> <option value="Shtepia e Femijes">Shtepia e Femijes</option> <option value="Teater">Teater</option> <option value="Kinema">Kinema</option> <option value="Qendra Kulturore">Qendra Kulturore</option> <option value="Monumente">Monumente</option> <option value="Stadium">Stadium</option> <option value="Pallati i Sportit">Pallati i Sportit</option> <option value="Kishe">Kishe</option> <option value="Xhami">Xhami</option> <option value="Televizione">Televizione</option> <option value="Muze">Muze</option> <option value="Cirku">Cirku</option> <option value="Banke">Banke</option> <option value="Qendra Biznesi">Qendra Biznesi</option> <option value="Kompani Sigurimesh">Kompani Sigurimesh</option> <option value="Rerstorant/Piceri">Rerstorant/Piceri</option> <option value="Night Clubs/Bars">Night Clubs/Bars</option> <option value="Hotele">Hotele</option> <option value="Agjensi Udhetimesh">Agjensi Udhetimesh</option> <option value="Stacioni i Trenit">Stacioni i Trenit</option> <option value="Sheshe/Parqe">Sheshe/Parqe</option> <option value="Universitet Privat">Universitet Privat</option> <option value="Universitet Shteteror">Universitet Shteteror</option> <option value="Librari ose Bibloteke ose Qendra Kursi">Librari ose Bibloteke ose Qendra Kursi</option> <option value="Rektorati">Rektorati</option> <option value="Spital">Spital</option> </select> </p> <p> <input type="submit" name="submit" value="Show objects" /> </p> </FORM> <p align="center"> </p> <p align="center"> </p> <form action="delete_object_fromDB.php" method="Post"> <span class="style11 style9"><strong>Object name</strong></span> <input type="text" name="object" id="object" /> <input type="submit" value="Delete" /> </form> </div></td> <td valign="top"> <div class="style9" id="side_bar" style="width: 100%; height: 60%;overflow: auto; border:1px solid black; background-color: #FFFFFF"> </div></td></tr> <tr><td align="center" valign="top"> </td> <td height="20" align="center" valign="top"> </td> </tr> </table> </body> </html> Code (markup):
Exactly!!! From the OP's original topic I feel trying to add AJAX in at this time would over-complicate things which is something I'm trying to avoid right now.
You can add that onto the start of your HTML file (be sure to rename it .php instead of .hmtl) and displaying the data inside your textbox will be a breeze - how to posted in other forum.
I've tried already, but it doesn't work, cause the page is too complicated, and when i put echo i display the data not in the div section.
<?php include("dbinfo.php"); $connection = mysql_connect($server,$username,$password); if (!$connection) { die('Not connected : ' . mysql_error()); } $db_selected = mysql_select_db($database, $connection); if (!$db_selected) { die ('Can\'t use db : ' . mysql_error()); } $result1=mysql_query("Select idg from Grupimi where grupim='$_POST[category]' and detaje='$_POST[subcategory]'") or die(mysql_error()); $row1 = mysql_fetch_array($result1); $klasifikimi = $row1['idg']; $result2=mysql_query("Select oemer from Objekt where klasifikimi='$klasifikimi'") or die(mysql_error()); if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Administration Page</title> <link rel="stylesheet" type="text/css" href="faqet.css"> <link rel="stylesheet" type="text/css" href="menut.css"> <link rel="shortcut icon" href="favicon.ico" /> </head> <body style="background-color: #000000;" onunload="GUnload()"> <center> <img src="logo8.gif" width="84%" height="200" style="margin-top: -1.3%; margin-bottom: -0.7%"> <table width="85%" height="45" border="0" cellpadding="0" cellspacing="0" style="margin-left: 8%; margin-right: 8%"> <tr><td><ul id="nav"> <li><strong><a href="http://clicktirana.com/Faqja2/Faqja2.htm"><span id="me">Clicktirana</span></a> </strong> </li> <li><strong><a href=""><span id="men">Map</span></a></strong> <ul> <li class="menu"><a href="http://clicktirana.com/adm" style="background-color: #000000 " >Add object</a></li> <li class="menu" ><a href="http://clicktirana.com/adm/update_object.html" style="background-color: #000000 " >Update object</a></li> <li class="menu" ><a href="http://clicktirana.com/adm/delete_object.html" style="background-color: #000000 " >Delete object</a></li> </ul> </li> <li><strong><a href=""><span id="g">Gallery</span></a></strong> <ul> <li class="menu"><a href="http://clicktirana.com/adm" style="background-color: #000000 " >Add photo</a></li> <li class="menu" ><a href="http://clicktirana.com/adm" style="background-color: #000000 " >Update photo</a></li> <li class="menu" ><a href="http://clicktirana.com/adm" style="background-color: #000000 " >Delete photo</a></li> </ul> </li> <li><strong><a href=""><span id="e">Events</span></a></strong> <ul> <li class="menu"><a href="http://clicktirana.com/adm" style="background-color: #000000 " >Add event</a></li> <li class="menu" ><a href="http://clicktirana.com/adm" style="background-color: #000000 " >Update event</a></li> <li class="menu" ><a href="http://clicktirana.com/adm" style="background-color: #000000 " >Delete event</a></li> </ul> </li> <li><strong><a href="http://clicktirana.com/Forum/forum.html"><span id="f">Users</span></a></strong></li> </u> </td></tr></table> </center> <!-- Delete form --> <table width="84%" b background="2323452136_45611f9411.jpg" height="200" cellpadding="0" cellspacing="0" style="margin-left: 8%" > <FORM ACTION="<?php echo $PHP_SELF;?>" METHOD=POST> <tr> <td width="51%" height="46"> <div align="center"><span class="style9 style11"><b>Choose category & subcategory:</b></span><br/> </div></td> <td width="49%"><div align="center"><span class="style9 style11"><b>Objects:</b></span><br/> </div></td></tr> <tr> <td valign="top" height="258"><div align="center"> <p> <select name="category" id="category" autocomplete="off"> <option value="-1">-------- Select one category -------</option> <option value="Institucione Shteterore">Institucione Shteterore</option> <option value="Institucione Kulturore,Fetare dhe Sportive">Institucione Kulturore,Fetare dhe Sportive</option> <option value="Institucione Financiare">Institucione Financiare</option> <option value="Hoteleri-Turizem">Hoteleri-Turizem</option> <option value="Institucione Arsimore">Institucione Arsimore</option> <option value="Institucione Shendetsore">Institucione Shendetsore</option> </select> </p> <p> <select name="subcategory" id="subcategory" autocomplete="off"> <option value="-1">--- Select one subcategory ---</option> <option value="Institucione Qeveritare">Institucione Qeveritare</option> <option value="Organet e Drejtesise">Organet e Drejtesise</option> <option value="Ambasada">Ambasada</option> <option value="Drejtori">Drejtori</option> <option value="Institucione Nderkombetare">Institucione Nderkombetare</option> <option value="Shtepia e Femijes">Shtepia e Femijes</option> <option value="Teater">Teater</option> <option value="Kinema">Kinema</option> <option value="Qendra Kulturore">Qendra Kulturore</option> <option value="Monumente">Monumente</option> <option value="Stadium">Stadium</option> <option value="Pallati i Sportit">Pallati i Sportit</option> <option value="Kishe">Kishe</option> <option value="Xhami">Xhami</option> <option value="Televizione">Televizione</option> <option value="Muze">Muze</option> <option value="Cirku">Cirku</option> <option value="Banke">Banke</option> <option value="Qendra Biznesi">Qendra Biznesi</option> <option value="Kompani Sigurimesh">Kompani Sigurimesh</option> <option value="Rerstorant/Piceri">Rerstorant/Piceri</option> <option value="Night Clubs/Bars">Night Clubs/Bars</option> <option value="Hotele">Hotele</option> <option value="Agjensi Udhetimesh">Agjensi Udhetimesh</option> <option value="Stacioni i Trenit">Stacioni i Trenit</option> <option value="Sheshe/Parqe">Sheshe/Parqe</option> <option value="Universitet Privat">Universitet Privat</option> <option value="Universitet Shteteror">Universitet Shteteror</option> <option value="Librari ose Bibloteke ose Qendra Kursi">Librari ose Bibloteke ose Qendra Kursi</option> <option value="Rektorati">Rektorati</option> <option value="Spital">Spital</option> </select> </p> <p> <input type="submit" name="submit" value="Show objects" /> </p> </FORM> <p align="center"> </p> <p align="center"> </p> <form action="delete_object_fromDB.php" method="Post"> <span class="style11 style9"><strong>Object name</strong></span> <input type="text" name="object" id="object" /> <input type="submit" value="Delete" /> </form> </div></td> <td valign="top"> <div class="style9" id="side_bar" style="width: 100%; height: 60%;overflow: auto; border:1px solid black; background-color: #FFFFFF"> <? }else{ while($row2 = mysql_fetch_array($result2)){ echo $row2['oemer']; echo "<br/>"; } } mysql_close($connection); ?> </div></td></tr> <tr><td align="center" valign="top"> </td> <td height="20" align="center" valign="top"> </td> </tr> </table> </body> </html> Code (markup):