Jump to content

ridzuan

New Members
  • Posts

    3
  • Joined

  • Last visited

ridzuan's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. hi, i need some help, in mysql query the output show as below :- 020000000000000000000790715035426 FIRSTNAME LASTNAME 800 000000000015900000000000013500000000000121700 but when i do <?php $data1 = mysql_query("SELECT * FROM details_view WHERE hashtotal = '$id'") or die(mysql_error()); while($info1 = mysql_fetch_array( $data1 )) { print $info1['details']; } ; ?> the output is :- 020000000000000000000790715035426 FIRSTNAME LASTNAME 800 000000000015900000000000013500000000000121700 How to make the php query same character length as mysql query? thank you.
  2. Hi, Current sql output:- A with 20 length/set | B with 5 length/set HelloWorld i want the output like below based on column length Hello<empty space 15char>World Thank you.
  3. Hi, I need some help here, i cant manage to settle this problem. Wish someone can help me. I want the result as below :- <ul class="navigation"> <li><a href="main-1.php">main-1</a></li> <li><a class="dropdown" href="main-2.php">main-2</a> <ul class="dropdown"> <li><a href="sub-21.php"></a>sub-1</li> <li><a href="sub-22.php"></a>sub-2</li> </ul></li> <li><a class="dropdown" href="main-3.php">main-3</a> <ul class="dropdown"> <li><a href="sub-31.php"></a>sub-1</li> <li><a href="sub-32.php"></a>sub-2</li> </ul></li> </ul> Here my output : - <ul class="navigation"> <li><a class="dropdown" href="main-1.php">main-1</li> <li><a class="dropdown" href="main-2.php">main-2</a> <ul class="dropdown"> <li><a class="dropdown" href="sub-21.php">sub-1</a></li> <li><a class="dropdown" href="sub-22.php">sub-2</a></li> </ul></li> <li><a class="dropdown" href="main-3.php">main-3</a> <ul class="dropdown"> <li><a class="dropdown" href="sub-31.php">sub-1</a></li> <li><a class="dropdown" href="sub-32.php">sub-2</a></li> </ul></li> </ul> Additional Info :- <?php $mysqli = new mysqli('localhost', 'root', '', 'localhost_test'); $query = 'SELECT id, parent_id, name, link FROM categories'; $result = $mysqli->query($query); if ($result->num_rows > 0) { $categories = array(); while($row = $result->fetch_assoc()) { if ($row['parent_id'] != 0) { $categories[$row['parent_id']]['sub'][] = $row; } else { $categories[$row['id']] = $row; } } echo '<ul class="navigation">'; foreach($categories as $cat) { echo '<li><a class="dropdown" href="' . $cat['link'] . '">'; if ($cat['parent_id'] == 0) { echo $cat['name']; } if (isset($cat['sub']) && is_array($cat['sub'])) { echo '</a><ul class="dropdown">'; foreach($cat['sub'] as $sub) { echo '<li><a class="dropdown" href="' . $sub['link'] . '">' . $sub['name'] . '</a></li>'; } echo '</ul>'; } echo '</li>'; } echo '</ul>'; } else { echo 'There are no categories'; } ?> SQL -- -------------------------------------------------------- -- Host: localhost -- Server version: 5.5.27 - MySQL Community Server (GPL) -- Server OS: Win32 -- HeidiSQL version: 7.0.0.4053 -- Date/time: 2013-03-08 09:28:54 -- -------------------------------------------------------- /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET NAMES utf8 */; /*!40014 SET FOREIGN_KEY_CHECKS=0 */; -- Dumping database structure for localhost_test CREATE DATABASE IF NOT EXISTS `localhost_test` /*!40100 DEFAULT CHARACTER SET latin1 */; USE `localhost_test`; -- Dumping structure for table localhost_test.categories CREATE TABLE IF NOT EXISTS `categories` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `parent_id` int(10) unsigned NOT NULL DEFAULT '0', `name` varchar(100) NOT NULL, `link` varchar(100) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=12 DEFAULT CHARSET=utf8; -- Dumping data for table localhost_test.categories: 7 rows /*!40000 ALTER TABLE `categories` DISABLE KEYS */; INSERT INTO `categories` (`id`, `parent_id`, `name`, `link`) VALUES (1, 0, 'main-1', 'main-1.php'), (2, 0, 'main-2', 'main-2.php'), (3, 2, 'sub-1', 'sub-21.php'), (4, 2, 'sub-2', 'sub-22.php'), (5, 0, 'main-3', 'main-3.php'), (6, 5, 'sub-1', 'sub-31.php'), (7, 5, 'sub-2', 'sub-32.php'); /*!40000 ALTER TABLE `categories` ENABLE KEYS */; /*!40014 SET FOREIGN_KEY_CHECKS=1 */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
×
×
  • 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.