Jump to content

mamleader

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mamleader's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. thanks guys you helped me I am stupid stupid I just forget that I am calling a variable outside the loop i just move } and it works :=wooo thanks
  2. thanks I think no wrong with query it comes when I am doing the fetch command btw I put all in a simple file <?php //header //mysql database connection $connection = mysql_connect("localhost","root","ikillu"); if(!$connection){die(mysql_error()); } //mysql database select $db_select = mysql_select_db("mam_cop",$connection); if(!$db_select){die(mysql_error());} function get_subjects_all() { global $connection ; $sub_query = "SELECT * FROM subjects ORDER BY position ASC"; $subject_query = mysql_query($sub_query,$connection)or die(mysql_error() . " IN $query"); //confirm_query($subject_query) ; return $subject_query; } function get_pages_all($subject_id) { global $connection; $query = "SELECT * FROM pages WHERE subject_id = '$subject_id' ORDER BY position ASC"; $page_set = mysql_query($query, $connection) or die(mysql_error() . " IN $query"); //confirm_query($page_set); return $page_set; } $subject_query = get_subjects_all(); while($subject = mysql_fetch_array($subject_query)) { echo $subject["menu_name"] . "<br />" ; } $all_pages = get_pages_all($subject["id"]); while($page = mysql_fetch_array($all_pages)) { echo $page["menu_name"] . "<br />" ; } ?> so you can figure easlly btw $subject_id called with $subject["id"] which is table -> row named id it continus id : 1 , 2 , .. etc
  3. hey I am still little new in php can you help me in this one func.php function confirm_query($result_set){ if(!$result_set){ die(mysql_error()); } function get_subjects_all() { global $connection ; $sub_query = "SELECT * FROM subjects ORDER BY position ASC"; $subject_query = mysql_query($sub_query,$connection); confirm_query($subject_query) ; return $subject_query; } function get_pages_all($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; } test.php require_once("config.php"); require_once("func.php"); $subject_query = get_subjects_all(); while($subject = mysql_fetch_array($subject_query)) { echo "<a href= \"test.php?subj=" . urlencode($subject["id"]) . "\">{$subject['menu_name']} <br />"; } $an = $subject["id"] ; $page_set = get_pages_all($an); while($page = mysql_fetch_array($page_set)) { echo "<a href = \"test.php?page=" . urldecode($page["id"]) . "\">{$page['menu_name']} </a><br />" ; // echo "<b> <a href= '1.php?page={$page['id']}' >{$page['menu_name']} </a></b> <br />"; } in this line WHERE subject_id = '$subject_id' the query don't work and gives me sql error i tried with this one ' ".$subject_id." ' but not worked but if i changed $subject_id to a number it work and read the data from the table thanks in advanced .
×
×
  • 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.