Jump to content

[Help] Navigation Links For Testing


Diether

Recommended Posts

Hi guys Good day. i want to print the id of navigation links for testing but i dont get any response. Pls help me guys to solve my problem. Thanks in advance

content.php

<?php require_once("includes/connection.php"); ?>
<?php require_once("includes/functions.php");?>
<?php include_once("includes/header.php");?>
<?php
if (isset($_GET['subj'])){
 $sel_subj = $_GET['subj'];
 $sel_page = "";
} elseif (isset($_GET['page'])) {
  $sel_subj = "";
  $sel_page = $_GET['']; 
}else{
   $sel_subj = "";
   $sel_page = "";	   
   }   
?>
 <table id = "structure">
  <tr>
    <td id = "navigation">
		  <ul class ="subjects">
		    <?php
		    $subject_set = get_all_subjects();
		    while ($subject = mysql_fetch_array($subject_set)) {
				    echo "<li><a href = \"content.php?subj = ". urlencode($subject["id"]) .
				    "\">{$subject["menu_name"]}</a></li>";			 
			  $page_set = get_page_for_subject($subject["id"]);
			  echo "<ul class = \"pages\" >";
			  while ($page = mysql_fetch_array($page_set)) {
				    echo "<li><a href = \"content.php?page = " . urlencode($page["id"]) .
					 " \">{$page["menu_name"] }</a> </li>";
			  }
		  echo "</ul>";
	    }
	  ?>
		  </ul>
  </td>
	    <td id = "page">
		  <h2>Content Area</h2>
		   <?php echo $sel_subj; ?></br>
		   <?php  echo $sel_page ; ?>
	    </td>
	   </tr>
 </table>
<?php require("includes/footer.php"); ?>

 

functions.php

<?php
function confirm_query($result_set){
   if (!$result_set) {
	    die("Database query failed: " . mysql_error());
	    }
}
function get_all_subjects(){
  global $connection;
  $query =   "SELECT *
  FROM subjects
	    ORDER BY position ASC";
  $subject_set = mysql_query($query, $connection);
  confirm_query($subject_set);
  return $subject_set;
}
function get_page_for_subject($subject_id){
  global $connection;
   $query = "SELECT * FROM pages
				  WHERE subject_id = {$subject_id}
				  ORDER BY position ASC";
	    $page_set = mysql_query($query, $connection);
  confirm_query($page_set);
  return $page_set;
}
?>

 

this is the part of my code that i want to print but no response when click the links

<?php
if (isset($_GET['subj'])){
 $sel_subj = $_GET['subj'];
 $sel_page = "";
} elseif (isset($_GET['page'])) {
  $sel_subj = "";
  $sel_page = $_GET['']; 
}else{
   $sel_subj = "";
   $sel_page = "";	   
   }   
?>

<?php echo $sel_subj; ?></br>
 <?php  echo $sel_page ; ?>

Link to comment
https://forums.phpfreaks.com/topic/272516-help-navigation-links-for-testing/
Share on other sites

  • 2 months later...
<?php 
// This block grabs the whole list for viewing
$product_list = "";
$sql = mysql_query("SELECT * FROM product 
           ORDER BY date_added DESC");
$productCount = mysql_num_rows($sql); // count the output amount
if ($productCount > 0) {
  $product_list .= "<table><tr><td>Product ID</td><td>Items</td><td>Price</td><td>Date</td><td>Action</td></tr>";
  
  while($row = mysql_fetch_array($sql)){
             $id = $row["id"];
       $product_name = $row["name"];
       $details = $row["details"];
       $size = $row["size"];
       $price = $row["price"];
       $quantity = $row["quantity"];
       $date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
       $product_list .= "<tr><td>$id</td> 
	   					<td><strong>$product_name</strong></td>
						<td>Php$price</td>
						<td><em>$date_added</em></td>
            		    <td><a href='inventory_edit.php?pid=$id'>edit</a> •
	                    <a href='inventory_list.php?deleteid=$id'>delete</a><br /></td></tr>";
        }
      } else {
        $product_list = "<tr><td colspan=5>You have no products listed in your store yet</td></tr>";
      }

?>

this solves my problem a while ago. hope it can help beginners :)

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.