Jump to content


Show And Hide Using PHP?


  • Please log in to reply
21 replies to this topic

#1 Guest_hauntmisery_*

Guest_hauntmisery_*
  • Guests

Posted 23 September 2006 - 09:03 AM

Hello, I have a bit of a problem here.. im pulling some data form mysql and i need to do a show and hide type thing but i cant seem to find anything that will work cause the data is in a WHILE loop form mysql.. so what do i do now?  :o

#2 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 23 September 2006 - 09:05 AM

What do you mean with "show and hide type thing"?

#3 Guest_hauntmisery_*

Guest_hauntmisery_*
  • Guests

Posted 23 September 2006 - 09:08 AM

like let me give you a example  go here http://www.spookyplanet.com/ and than cick on Animations under the categories youll see the sub list come under Animations

#4 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 23 September 2006 - 09:10 AM

That would be a matter of CSS, but I am not sure what you got problems with? Do you create the menu dynamically? Is that the problem?

#5 Guest_hauntmisery_*

Guest_hauntmisery_*
  • Guests

Posted 23 September 2006 - 09:13 AM

yes thats is the problem i have posted my code below

<tr>
                <td><img src="images/cat_left_top.jpg" width="180" height="40"></td>
              </tr>
			  <?
			  $categories = mysql_query("SELECT * FROM `store_categories` ORDER BY `id`"); 
              while ($categoriesget = mysql_fetch_array($categories)) { 
			  ?>
              <tr>
                <td class="cat_text">
                  <a href="?list=<?=$categoriesget[id]?>"><?=$categoriesget[categorie_name];?></a>
				
			<? 
			if ($_GET['list']) {
			$categorie_list = mysql_query("SELECT * FROM `store_categorie_list` WHERE list_categorie_id='$_GET[list]' ORDER BY `id`"); 
            while ($categorie_list_get = mysql_fetch_array($categorie_list)) {
			echo "<br><br>--- $categorie_list_get[list_name]";
			}
			}
			?>
				
				  </td>
              </tr>
			 
              <tr>
                <td height="0"><hr align="center" width="170" size="1" noshade class="cat_bar"></td>
              </tr> <?
			  }
			  ?>


#6 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 23 September 2006 - 09:13 AM

What errors do you get using that code?

#7 Guest_hauntmisery_*

Guest_hauntmisery_*
  • Guests

Posted 23 September 2006 - 09:15 AM

none.. it just shows the sub list in all main cats

Home Decor

--- Test 1 

--------------------------------------------------------------------------------

Illusions

--- Test 1 

like that..

#8 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 23 September 2006 - 09:15 AM

Can you post a screenshot or give me a link to the site?

#9 Guest_hauntmisery_*

Guest_hauntmisery_*
  • Guests

Posted 23 September 2006 - 09:21 AM

it dose this..

Home Decor

--- Test 1 

--------------------------------------------------------------------------------

Illusions

--- Test 1 

#10 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 23 September 2006 - 09:25 AM

You don't like have a screenshot of your output? For what I can tell from what you posted, it looks ok.

#11 Guest_hauntmisery_*

Guest_hauntmisery_*
  • Guests

Posted 23 September 2006 - 09:30 AM

ill give you a link..

http://www.nightmare...onster-tronics/

click on home decor and illsusions

#12 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 23 September 2006 - 09:38 AM

Try this code:
<?php
echo <<<EOF
	<tr>
		<td><img src="images/cat_left_top.jpg" width="180" height="40"></td>
	</tr>

EOF;
$categories = mysql_query("SELECT * FROM store_categories ORDER BY id");
while($c = mysql_fetch_assoc($categories))
{
	echo <<<EOF
	<tr>
		<td class="cat_text">
			<a href="?list={$c['id']}"{$c['categorie_name']}</a>
				
EOF;
	if($_GET['list'])
	{
		$_GET['list'] = mysql_real_Escape_string($_GET['list']);
		$c_list = mysql_query("SELECT * FROM store_categorie_list WHERE list_categorie_id='{$_GET['list']}' ORDER BY id");
		while($c_list_item = mysql_fetch_assoc($c_list))
		{
			echo "\t\t\t<br /><br/>--- {$categorie_list_get['list_name']}\n";
		}
	}
	echo <<<EOF
		</td>
	</tr>

EOF;
}
echo <<<EOF
	<tr>
		<td height="0"><hr align="center" width="170" size="1" noshade class="cat_bar"></td>
	</tr>

EOF;
?>


#13 Guest_hauntmisery_*

Guest_hauntmisery_*
  • Guests

Posted 23 September 2006 - 09:41 AM

Parse error: syntax error, unexpected $end in /home/nightdes/public_html/previews/monster-tronics/index.php on line 279


#14 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 23 September 2006 - 09:43 AM

That must be something you did. My code could in no possible way make that error. Show us the entire code from index.php and we will show you how to implement the code correctly.

#15 Guest_hauntmisery_*

Guest_hauntmisery_*
  • Guests

Posted 23 September 2006 - 09:46 AM

still doing the same sub cats in the main cats thang..

#16 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 23 September 2006 - 10:15 AM

Try this:
echo <<<EOF
	<tr>
		<td><img src="images/cat_left_top.jpg" width="180" height="40"></td>
	</tr>

EOF;

$categories = mysql_query("SELECT * FROM store_categories ORDER BY id");

while($c = mysql_fetch_assoc($categories))
{
	echo <<<EOF
	<tr>
		<td class="cat_text">
			<a href="?list={$c['id']}"{$c['categorie_name']}</a>

EOF;
	if(isset($_GET['list']) && is_numeric($_GET['list']) && $_GET['list'] == $c['id'])
	{
		$_GET['list'] = mysql_real_Escape_string($_GET['list']);
		$c_list = mysql_query("SELECT * FROM store_categorie_list WHERE list_categorie_id='{$_GET['list']}' ORDER BY id");

        echo "\t\t\t<p>\n";

        while($c_list_item = mysql_fetch_assoc($c_list))
		{
			echo "\t\t\t--- {$categorie_list_get['list_name']}<br />\n";
		}
	}
	echo <<<EOF
            </p>
		</td>
	</tr>

EOF;
}
echo <<<EOF
	<tr>
		<td height="0"><hr align="center" width="170" size="1" noshade class="cat_bar"></td>
	</tr>

EOF;


#17 Guest_hauntmisery_*

Guest_hauntmisery_*
  • Guests

Posted 23 September 2006 - 10:21 AM

Parse error: syntax error, unexpected $end in /home/nightdes/public_html/previews/monster-tronics/index.php on line 278

EDIT:
Parse error: syntax error, unexpected $end in /home/nightdes/public_html/previews/monster-tronics/index.php on line 282

#18 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 23 September 2006 - 10:40 AM

You must of done something to your code, when you copied and pasted the code over, all I did was mofify the if statement. Make sure EOF; is not indented and is on its own line with no whitespace before or after it.

#19 Mutley

Mutley
  • Members
  • PipPipPip
  • Advanced Member
  • 765 posts

Posted 23 September 2006 - 10:40 AM

Those codes are both error free. Post ALL the code to your index.php Your probably missing a closed curley bracket at the end.
~ Mutley.

#20 Guest_hauntmisery_*

Guest_hauntmisery_*
  • Guests

Posted 30 September 2006 - 01:34 PM

i could never get this to work...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users