954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Transform html to dynamic php of hierarchical data

Hi there,
I've made this page in html:
http://www.greenbeanbaby.com/retailers.php
with drop-down menus that work.

But when I try to make it dynamic for my client to update it, I'm stuck! The drop downs don't work.
Here is the code I'm using:

$r=mysql_query("SELECT * FROM retailer");
	$varloop=1;
	echo "<div id='wrap'>";
	while(list($idr, $name)=mysql_fetch_array($r)){
		//echo "$name";
		//echo "";
			
		$r2=mysql_query("SELECT idp, provinces FROM province WHERE parentidr='$idr'") or die(mysql_error());
		while(list($idp, $provinces)=mysql_fetch_array($r2)){
			echo ("<span class='product-menu'>");
			echo "$provinces";
			echo ("</span>");
			echo ("<a href='#' id='example.$varloop.-show' class='showLink' onclick='showHide(example.$varloop);return false;'><img src='../images/retailer-down.gif' alt='retailer' width='10' height='8' class='img' /></a>");
			echo ("<div id='example.$varloop' class='more'><a href='#' id='example.$varloop.-hide' class='hideLink' onclick='showHide(example.$varloop);return false;'><img src='../images/retailer-up.gif' alt='retailer' width='10' height='8' class='img' /></a>");
			echo "";
			$varloop++;
			//echo $varloop;
				
			$r3=mysql_query("SELECT idc, cities FROM city WHERE parentidp='$idp'") or die(mysql_error());
			while(list($idc, $cities)=mysql_fetch_array($r3)){
				echo ("<span class='bold'>");
				echo "$cities";
				echo ("</span>");
				echo "";
					
				$r4=mysql_query("SELECT ids, stores, website, link, phone FROM store WHERE parentidc='$idc' AND parentidp='$idp'") or die(mysql_error());
				while(list($ids, $stores, $website, $link, $phone)=mysql_fetch_array($r4)){
					echo "$stores";
					echo " ";
					echo ("<a href='$link' target='_blank' class='second'>");
					echo "$website";
					echo ("</a>");
					echo " ";
					echo "$phone";
					echo "";
				}			
	                }
		echo ("</div>");
		echo "";
		}
	}
		
	echo "</div>";

Can someone help me find my mistake please?

Thank you!

bouhbob
Newbie Poster
14 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

I looked at this site and I don't see any working drop-down menus.

I'm not prepared to spend the time doing the debugging that you need to do. Maybe someone else is but that may be why you don't have any responses yet. If you at least showed what was working and then specifically what you changed, there might be a chance that someone would spot something wrong in the changes.

chrishea
Nearly a Posting Virtuoso
1,428 posts since Sep 2008
Reputation Points: 210
Solved Threads: 230
 

Hi,
Thank you for the remark...

So I guess I did not explain properly: the drop-down are next to the provinces "Alberta"..., the little triangle that indicates 'down': this opens a list of stores. And you can find the html code by viewing the page source.
So you can compare the html code and the php code that is up here in my first post.

I hope this is enough new info.

Thank you for any help.

bouhbob
Newbie Poster
14 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

Help please!

bouhbob
Newbie Poster
14 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

I'm gonna close this discussion but I thought I would give you the answer, as I found it from a friend of mine:
Changes are in red

Line 13 echo ("retailer");

Line 14 echo ("retailer");

Hope this can help some of you, unless my code is really bad anyway! At least it works for now!
Cheers

bouhbob
Newbie Poster
14 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 
Changes are in red


Well that certainly helps! :)

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: