Jump to content

Show/Hide db row on selection.


Kleidi

Recommended Posts

Hello!

 

I'm looking around for a way to show/hide some db results depending on a checkbox or dropdown selection. Ex:

If i have 3 pages and i don't want that the page number 2 to appear, i check a box and save ti or select the option in dropdown menu and that page is not anymore visible.

Any help please?

Thank you in advance!

Link to comment
https://forums.phpfreaks.com/topic/196479-showhide-db-row-on-selection/
Share on other sites

<?php
if (!isset($_GET['id'])) // if $_GET['id'] is NOT set
{
   include 'D:/Program Files/VertrigoServ/www/joni/admini/includet/variabla.php';
   include (BPATH . '/includet/dbconfig.php');
   $query="SELECT * FROM `faqe` ORDER BY `faqe`.`ID`";
   $result=mysql_query($query);
   $num=mysql_numrows($result);
   
   mysql_close();
?>
<!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">
<!--Ketu fillon seksioni Head Indexin -->
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="generator" content=":!:!: Albmania Host & Design :!:!:" />
<meta name="robots" content="Follow, Index" />
<meta name="author" content="Feriold O." />
<meta name="copyright" content=" © 2009 Mundesuar nga Albmania Host and Design - Feriold O." />
<meta http-equiv="Pragma" content="no-cache" />
<meta content="no-cache" http-equiv="no-cache" />
<meta name="revisit-after" content="1 DAYS">
<meta http-equiv="Cache-Control" content="no-cache" />
<title>Watch Live Football Games For Free</title>
<meta name="description" content=" " />
<meta name="keywords" content=" " />
<link href="stildizenjimi.css" rel="stylesheet" type="text/css" />
    <script src="http://localhost/live/js/skripte.js" type="text/javascript"></script>
<link rel="shortcut icon" href="favicon.ico" >
</head>

<!--Ketu mbaron seksioni i Head për Indexin-->


<!--Ketu fillon Trupi i indexit -->

<body>
<?php
   $i=0;
   while ($i < $num) {
   $id=mysql_result($result,$i,"id");
   $emri=mysql_result($result,$i,"emri");
   $teksti=mysql_result($result,$i,"teksti");
   $tag=mysql_result($result,$i,"tag");
   $permalink=mysql_result($result,$i,"permalink");
  ?>
<div class="trupi" align="center">
<div class="koka">
    	</div>
<div class="pastro"></div>
  <div class="qender">
    	
        <div class="qendersiper">
        <div class="qendersipermenu"> |<a href="http://localhost/joni/">Fillimi</a> |<a href="<?php echo $id;  ?>_<?php echo $permalink;  ?>"> <?php echo $emri;  ?></a> | 
        <?php
   $i++;
   }
   ?>	
    </div>
        </div>

        <div class="majtas">Majtas
        </div>
        
        <div class="djathtas">Djathtas </div>
  </div>        <div class="pastro"></div>
</div>
<!-- Ketu mbaron trupi i Indexit-->
</body>
</html>
<?php
} // end if()
else // $_GET['id'] IS set
{
   if (!empty($_GET['id'])) // if $_GET['id'] is NOT empty
   {
      
  
 // added by Kleidi: getting infos from db
  include 'D:/Program Files/VertrigoServ/www/joni/admini/includet/variabla.php';
 include (BPATH . '/includet/dbconfig.php');
   $query="SELECT * FROM `faqe` WHERE id = '$_GET[id]'";
   $result=mysql_query($query);
   $num=mysql_numrows($result);
   
   $id=mysql_result($result,$i,"id");
   $emri=mysql_result($result,$i,"emri");
   $teksti=mysql_result($result,$i,"teksti");
   $permalink=mysql_result($result,$i,"permalink");
   $tag=mysql_result($result,$i,"tag");
   // added by Kleidi: end of getting infos from db
?>
<!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">
<!--Ketu fillon seksioni Head per ndeshjen -->
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="generator" content=":!:!: Albmania Host & Design :!:!:" />
<meta name="robots" content="Follow, Index" />
<meta name="author" content="Feriold O." />
<meta name="copyright" content=" © 2009 Mundesuar nga Albmania Host and Design - Feriold O." />
<meta http-equiv="Pragma" content="no-cache" />
<meta content="no-cache" http-equiv="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache" />
<title>Agalliu.Com - <?php echo $emri;  ?></title>
<meta name="description" content="" />
<meta name="keywords" content="" />
<link href="http://localhost/joni/stildizenjimi.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="favicon.ico" >
      </head>

<!--Ketu mbaron seksioni i Head për ndeshjen-->


<!--Ketu fillon Trupi i ndeshjes-->

<body>
<?php
   $i=0;
   while ($i < $num) {
   $id=mysql_result($result,$i,"id");
   $emri=mysql_result($result,$i,"emri");
   $teksti=mysql_result($result,$i,"teksti");
   $tag=mysql_result($result,$i,"tag");
   $permalink=mysql_result($result,$i,"permalink");
  ?>
<div class="trupi" align="center">
<div class="koka">
    	</div>
<div class="pastro"></div>
  <div class="qender">
    	
        <div class="qendersiper">
        <div class="qendersipermenu"> |<a href="http://localhost/joni/">Fillimi</a> |<a href="<?php echo $id;  ?>_<?php echo $permalink;  ?>"> <?php echo $emri;  ?></a> | 
        <?php
   $i++;
   }
   ?>	
    </div>
        </div>

        <div class="majtas">Majtas
        </div>
        
        <div class="djathtas"><b><?php echo $emri;  ?> </b> <br /> <br />
        	<?php echo $teksti;  ?><br /> <br />
            <i><?php echo $tag;  ?></i>
        </div>
  </div>        <div class="pastro"></div>
</div>
<!-- Ketu mbaron trupi i Indexit-->
</body>
</html>
</html>
<?php     // code to get movie information from database and output it
   } // end if()
} // end else
?> 

That's the index.php

My db looks like this:

`id` int(6) NOT NULL auto_increment,
  `emri` varchar(255) NOT NULL default '',
  `permalink` varchar(255) NOT NULL default '',
  `teksti` text NOT NULL,
  `tag` varchar(255) NOT NULL default '',
  `aktive` enum('N','Y') NOT NULL default 'N',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;

 

And rows looks like this:

INSERT INTO `faqe` (`id`, `emri`, `permalink`, `teksti`, `tag`, `aktive`) VALUES
(1, 'Any Name', 'any_name/', 'some text here', 'any, name, here', 'Y');
INSERT INTO `faqe` (`id`, `emri`, `permalink`, `teksti`, `tag`, `aktive`) VALUES
(2, 'That Name', 'that_name/', 'some text here too', 'that, name, here', '');

 

Now, what i need is a way to show only the rows that are aktive=Y. I tried:

$query="SELECT * FROM `faqe`  WHERE `faqe`.`aktive` = `Y` ORDER BY `faqe`.`ID`";

but i received this error:

Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in D:\Program Files\VertrigoServ\www\xxxx\index.php  on line 8

 

and line 8 is this one:

   $num=mysql_numrows($result);

 

Hope that i was understandable and someone can help me.

 

Thank you in advance!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.