Jump to content


Photo

dynamic


  • Please log in to reply
21 replies to this topic

#21 kusal

kusal
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts
  • LocationSri Lanka - Colobmo

Posted 07 July 2006 - 07:04 AM

can i use show table and describe table_name to get the info,

let say that i get those info but how can i create relevant html page and php pages.
www.kuppiya.com

#22 hackerkts

hackerkts
  • Members
  • PipPipPip
  • Advanced Member
  • 593 posts
  • LocationSingapore
  • Age:18

Posted 07 July 2006 - 08:31 AM

Eh.. Can you explain to me what does you mean by show table and describe ?

Try this sample, hope it's what you looking for.

MySQL table structure:
CREATE TABLE `handphone` (
`id` MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`type` TEXT NOT NULL ,
`servers` TEXT NOT NULL ,
`desks` TEXT NOT NULL ,
`monitors` TEXT NOT NULL ,
`phones` TEXT NOT NULL
)

MySQL datas:
INSERT INTO `handphone` VALUES (1, 'type1', 'servers1', 'desks1', 'monitors1', 'phones1');
INSERT INTO `handphone` VALUES (2, 'type1', 'servers2', 'desks2', 'monitors2', 'phones2');
INSERT INTO `handphone` VALUES (3, 'type1', 'servers3', 'desks3', 'monitors3', 'phones3');
INSERT INTO `handphone` VALUES (4, 'type2', 'servers1', 'desks1', 'monitors1', 'phones1');
INSERT INTO `handphone` VALUES (5, 'type2', 'servers2', 'desks2', 'monitors2', 'phones2');
INSERT INTO `handphone` VALUES (6, 'type2', 'servers3', 'desks3', 'monitors3', 'phones3');
INSERT INTO `handphone` VALUES (7, 'type3', 'servers1', 'desks1', 'monitors1', 'phones1');
INSERT INTO `handphone` VALUES (8, 'type3', 'servers2', 'desks2', 'monitors2', 'phones2');
INSERT INTO `handphone` VALUES (9, 'type3', 'servers3', 'desks3', 'monitors3', 'phones3');

Scripts
<?php
mysql_connect("localhost", "root","") or die(mysql_error());
mysql_select_db("hp") or die(mysql_error());
if (isset($_GET['type'])) {
	$result = mysql_query("SELECT * FROM handphone WHERE type='".$_GET['type']."'") or die("Query failed: " . mysql_error());
    	while($row = mysql_fetch_assoc($result)) {
        ?>
        <table width="560" border="1" align="center" cellpadding="2">
  		 <tr>
  		  <td><strong>Servers: </strong><?php echo $row['servers']; ?></td>
  		</tr>
  		<tr>
  		  <td><strong>Desks: </strong><?php echo $row['desks']; ?></td>
  		</tr>
  		<tr>
  		  <td><strong>Monitors: </strong><?php echo $row['monitors']; ?></td>
  		</tr>
  		<tr>
  		  <td><strong>Phones: </strong><?php echo $row['phones']; ?></td>
  		</tr>
		</table><br>
        <?php
        }
} else {
	echo "You didn't select any type.";
    }
?>

If you save the code in index.php, then you can access it from http://domain/index.php?type=1 or type=2 or type3
It will display according to your type.

Regards,
hackerkts

To be a coder, you must learn how to think and not to give up so easily.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users