Jump to content

Theonlybrains

Members
  • Posts

    9
  • Joined

  • Last visited

Theonlybrains's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Thank you guys I will review my html code, and the syntax. I real appreciate your help.
  2. I did check the syntax and that does not seem to be the problem. The closing tag got lost while I was posting on here!
  3. <!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"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Brain Corp</title> <link href="stylesheets/public.css" media="all" rel="stylesheet" type="text/css" /> </head> <body><div id="header"><h1>Brain Corp</h1> </div> <div id= "main"> <table id="structure"> <tr> <td id="navigation"> <ul class="subjects">
  4. Thanks for looking,This is the code, the connection to the database works ok though, Everything worked fine until included the links.<?php require_once("includes/db_connection.php");?><?php require_once("includes/functions.php");?><?php include("includes/header.php");?><?php?><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=\"content1.php?subj=".urlencode($subject["id"])."\">{$subject["menu_name"]}</a></li>";$page_set = get_pages_for_subject($subject["id"]);echo "<ul class=\"pages\">";while($page = mysql_fetch_array($page_set)){ echo "<li><a href =\"content1.php?page=".urlencode($page["id"]). "\"{$page["menu_name"]}</li>";}echo "</ul>";}?><!-- </ul> --></td><td id= "page"><h2> Content Menu</h2><?php echo $selected_subj; ?><br /><?php echo $selected_subj; ?><br /></td></tr></table><?php require("includes/footer.php");?> Before adding the links,my code was:<?php$subject_set = get_all_subjects();while($subject= mysql_fetch_array($subject_set)){ echo "<li>{$subject["menu_name"]}</li>";$page_set = get_pages_for_subject($subject["id"]);echo "<ul class=\"pages\">";while($page = mysql_fetch_array($page_set)){ echo "<li>{$page["menu_name"]}</li>";}echo "</ul>";}?></ul>The code gave me the list of all the subjects, after adding the links, the list disappears and I am only left with bullets points. Where I hoover the mouse around where the list was, it shows that there is a link about bout and if you click it changes on the address bar, before the click: localhost/brain_corp/content1.phpand after the click : localhost/brain_corp/content1.php?subj=2thanks again, please be patient with me as I am still trying to learn my way around php.Thanks again
  5. hi, this is the functions that I have included: <?php// this is a basic functions file 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_pages_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;}?>Thanks
  6. Hi Guys,I am trying to add links to my menus for that the navigation becomes dynamic, when I include the links my menus disappear and I am left with bullet points and when I hoover the mouse around the menu arrears it shows that a link has been created even though there is no text visible. When I click it shows me that the link has taken me to a different area according to the menu. Please help me identify where I am going wrong for the text to disappear the code is as follows: <?php$subject_set = get_all_subjects(); while($subject= mysql_fetch_array($subject_set)){ echo "<li><a href=\"content1.php?subj=".urlencode($subject["id"])."\">{$subject["menu_name"]}</a></li>";$page_set = get_pages_for_subject($subject["id"]);echo "<ul class=\"pages\">";while($page = mysql_fetch_array($page_set)){ echo "<li><a href =\"content1.php?page=".urlencode($page["id"]). "\"{$page["menu_name"]}</li>";}echo "</ul>";}?> </ul> Many thanks
  7. Thanks guys for your help, I do not seem to understand where I am going wrong with this! I have created the link to my description page and that works fine. Now I just can get my head round to creating a query or a function to the retrieve individual insect description! this is what my description page code looks like:<?php // Make a connection to the host servermysql_connect("localhost","xxxxxx","xxxxxxxx") or die(mysql_error);mysql_select_db("khumbu") or die(mysql_error());/*create a new mysql query to select insects from a selected table*/$insects = mysql_query ("SELECT insect_id, insect_slug, insect_com, insect_science,insect_des FROM insects");$row = $_Get['insect_id']; echo "<table border ='1'";echo "<h1>Insect Description</h1>";echo "<tr><th>insect_des</th></tr>";echo "<tr><td>"; echo $row['insect_des'];echo "</td></tr>"; echo "</table>";?> I am getting an error that say undefined variable GetPlease help
  8. Thanks ckrudelux,I have created the link page which seems to work fine, but I cant get my head round using the $_GET['insect'] , What I am trying to do is that if I click on any insect, the link should take me to the description of that particular insect. At the moment when I click I just land on the description page. Like I said I am fairly new to php and kind of having teething problems! create a while loop to get the rows of the table */while($row = mysql_fetch_array( $insects )) {$strInsect = $row ['insect_com'];$strDescription = $row['insect_des'];//create a link to the insect description page$strLink = "<a href='descriptionpage.php?insect_des = ". $row['insect_com']. "'>".$strInsect."</a>"; // Print out the contents of each row into a tableecho "<tr><td>"; echo $row['insect_slug'];echo "</td><td>";echo $strLink;echo "</td><td>"; echo $row['insect_science']; echo "</td></tr>"; this creates a table with three columns and the insect_com acts as a link to the the description page.My challenge now is how do I create the link so that it points to individual description of each insect rather than the whole page? thanks
  9. HiI am fairly new to php, I have a table that has insect names, id, scientific name and descriptions. I am trying to present the table with insect Id name and scientific name. The insect description is too long to fit into the table I therefore want to create a link to a different page which will give the insect description then link back to the home page. I have been trying to find some info on using the get function to retrieve the data but no luck!this what my code looks like: /*create a new mysql query to select insects from a selected table*/$insects = mysql_query ("SELECT insect_id, insect_slug, insect_com, insect_science, insect_desFROM insectsORDER BY insect_com"); echo "<table border ='1'";echo "<h>insects</h>";echo "<tr><th>insect_slug</th><th>insect_com</th><th>insect_science</th></tr>"; /* create a while loop to get the rows of the table */while($row = mysql_fetch_array( $insects )) {$strInsect = $row ['insect_com'];//create a link to the insect description page$strLink = "<a href='insects-details.php?insect_des = ". $row['insect_com']. "'>".$strInsect."</a>"; // Print out the contents of each row into a tableecho "<tr><td>"; echo $row['insect_slug'];echo "</td><td>";echo $strLink;echo "</td><td>"; echo $row['insect_science']; echo "</td></tr>"; //echo "<li>".$strLink."</li>"; }echo "</table>"; ?>Thanking you in advance
×
×
  • Create New...