Jump to content

alinash33

New Members
  • Content Count

    4
  • Joined

  • Last visited

Community Reputation

0 Neutral

About alinash33

  • Rank
    Newbie
  1. Hi I'm a beginner so maybe I didn't understand the logic -what I have is a categories table within it I have a 3 fields : id , category, parent the id is the primary key the items in category have id(primary key) and they also have a number of parent from 0 to 4 . The category that assigned parent=0 should be the header link in the and below it the category with parent 1 2 3 4 et... so variable parent_id receives fro the parent[id] the 1,2,3,4 and from there it goes to the query of sql2 that puts in $sql 2 all the category that have parent 1,2,3,4 .I'm really beginner so maybe something is wrong with my logic.Would be very grateful for your help.
  2. I'm building a site with bootstrap and trying to make the menu dynamic.created a database with xampp.it seems that there is connection because it showed some errors that I fixed.But now there are no erorrs but the data doesn't show on the website. it should be navigation menu with sublinks. Here is my code: would be very grateful for your help <?php $sql = "SELECT * FROM categories WHERE parent=0"; $pquery = $db->query($sql);?> <nav class="navbar navbar-default navbar-fixed-top" id="navbar" > <div class="container"> <a href="index.php" class="navbar-brand" id="text">Kippah store</a> <ul class="nav navbar-nav"> <?php while($parent = mysqli_fetch_assoc($pquery));?> <?php $parent_id= $parent['id']; $sql2 = "SELECT * FROM categories WHERE parent='parent_id'"; $cquery = $db->query($sql2); ?> <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown" id="text"><?php echo $parent['category'];?><span class="caret"></span></a> <ul class="dropdown-menu" role="menu"> <?php while($child = mysqli_fetch_assoc($cquery));?> <li><a href="#"><?php echo $child['category'];?></a></li> </ul> </li> </ul> </div> </nav>
  3. Ok so I have installed Wamp server on windows 10.Details:Apache 2.4.23 - PHP 5.6.25 - MySQL 5.7.14 PHP 5.6.25 for CLI (Command-Line Interface). I made a simple database in phpmyadmin to check connectivity to the database. database name="news" with one table table="info_news" I have the index.php in the www folder of wamp The wamp Icon is green running on port 80 I tried 3 different codes to connect to database: old mysql connection,mysqli coonection,PDo connection I didn't succeed to connect with either of them. I stop trying with old mysql and pdo and I'm focused now on mysqli. This is the code on my index.php: <?php> $hostname = "localhost"; $username = "root"; $password = ""; $dbname = "news"; $conn = new mysqli('localhost', 'root', ' ', 'news'); // Check connection if ($mysqli->connect_error) { die('Connect Error (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error); } echo 'Connection OK'; $mysqli->close(); $myquery = "select * from info_news"; if (mysqli_query($conn, $myquery)) { echo "Records retrieved."; } else { echo "Error : " . mysqli_error($conn); } ?> When I check this on the browser this is what I get:Navigation to the webpage was canceled What you can try: Retype the address. I tried to change the localhost to '127.0.0.1' but the result is the same. What did I miss? What is my mistake? I really want just this simple success of connection.
×
×
  • 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.