Solved

Div Not Populating

Posted on 2013-05-18
2
415 Views
Last Modified: 2013-05-18
I have a div that was populating, then it stopped.  Its off of this javascript.

$("#Menus").click(function()
			{
			var Lid = $("#Restaurant").val();
			var MenuTypeId = $(this).val();
    		$.ajax({
				type: "POST",
        		url: "../Scripts/result_menus_new.php",
        		data: {"Lid": Lid,"MenuTypeId": MenuTypeId},
				cache: false,
        		success: function (html) {
          		//alert (Menus);
				$("#MyMenus").html(html);
        		}
    			});
				});
    			});	

Open in new window


I tested the querys that it invokes and they all work fine.  Here is the php file.

<div id=BigName>
<?PHP
	include("config.php");
	$Lid=$_POST['Lid']= mysql_real_escape_string($_POST['Lid']);
	$MenuTypeId=$_POST['MenuTypeId']= mysql_real_escape_string($_POST['MenuTypeId']);
	
	//$Lid = $_POST['Lid'];
	//$MenuTypeId = $_POST['MenuTypeId'];
	//select menu type
	$run = mysql_query("select * from tblMenuType where MenuTypeID='$MenuTypeId'") or die(mysql_error());
	$row = mysql_fetch_array($run) or die(mysql_error());
	$menu_type_name = $row['MenuTypeName'];
	
			if(!$rs=mysql_query("SELECT tblRestaurants.RestName
			FROM
			tblRestaurants
			INNER JOIN tblLocations ON tblRestaurants.RestID = tblLocations.RestID
			WHERE tblLocations.LocationID = '$Lid'")) {
			echo "Cannot parse query";
					}
				else
			 		{
			
			echo "<table id=\"BigName\" class =\"BigName\" table width=\"450\" align=\"Center\" cellspacing=\"0\">\n";
			while($row = mysql_fetch_array($rs)) {
      		echo "<tr><strong><td align='center' style='padding-top: 10px;'>".$row['RestName']."</td></strong></tr>";}
      		echo "</tr>\n";
				} 
		?>	
</div>

<div id=BigPhone>
<?PHP

			if(!$rs=mysql_query("SELECT tblLocations.Phone
			FROM
			tblLocations
			WHERE tblLocations.LocationID = '$Lid'")) {
			echo "Cannot parse query";
					}
				else
			 		{
			echo "<table id=\"BigPhone\" class =\"BigPhone\" table width=\"450\" align=\"Center\" cellspacing=\"0\">\n";
			
			while($row = mysql_fetch_array($rs)) {
      		echo "<tr><strong><td align='center' style='padding-top: 10px;'>".$row['Phone']."</td></strong></tr>";
			}
			echo "<tr><strong><td align='center' style='padding-top: 10px;'>".$menu_type_name."</td></strong></tr>";
      		echo "</tr>\n";
				} 
		?>	
</div>


<div id="MyMenus">
<?php
			if(!$rs=mysql_query("SELECT tblMenuItems.ItemName, tblMenus.ItemPrice,tblMenuCat.CatName
					FROM tblMenuItems
					INNER JOIN tblMenus ON tblMenuItems.ItemID = tblMenus.ItemID
					INNER JOIN tblLocMenu ON tblLocMenu.MenuID = tblMenus.MenuID
					INNER JOIN tblMenuCat ON tblMenus.ItemCat = tblMenuCat.CatID
					WHERE tblLocMenu.LocationID = '$Lid' AND tblMenus.MenuTypeId = '$MenuTypeId'
					GROUP BY tblMenus.ItemID")) {
			echo "Cannot parse query";
					}
				else
			 		{
			echo "<table id=\"MyMenus\" table width=\"200\" align=\"Center\" cellspacing=\"0\">\n";
			echo "<tbody>";
			
			$Cat="";
			while($row = mysql_fetch_array($rs)) {
      			If($Cat!=$row['CatName']){
				echo "<tr><strong><td align='left' style='padding-top: 10px;'>".$row['CatName']."</td></strong></tr>";					
				}
      				$Cat=$row['CatName'];
				echo "<tr>";
      			echo "<td align='left' style='padding-left: 25px;'}>".$row['ItemName']."</td>";
      			echo "<td align='right'>".$row['ItemPrice']."</td>";
      			echo "</tr>\n";
				echo "</tbody>";
				} 
				}
?>
</div>

Open in new window

0
Comment
Question by:DS928
2 Comments
 
LVL 26

Accepted Solution

by:
skullnobrains earned 500 total points
ID: 39177438
you need some more debugging.

uncoment the alert in the js code during the debug time and add a failure callback so you can tell wether you're not getting the proper data or no data at all, or possibly the ajax query never fired
0
 

Author Closing Comment

by:DS928
ID: 39177445
Found it.  I failed to put the MenuTypeID field in the select part.  Thank you.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now