Calling variables
Posted on
16th Feb 2014 07:03 pm by
admin
I want to call this to my website but it doesn't display what I want it to,
Code: <h5>Edit Subject: <?php echo $sel_subject['menu_name']; ?></h5>
If I change the $sel_subject to $sel_page it works, but both are using the exact same names in the database and have exactly the same code in my functions.php
Can anyone help?
functions.php
Code: function get_subject_by_id($subject_id) {
global $connection;
$query = "SELECT * ";
$query .= "FROM subjects ";
$query .= "WHERE id=" . $subject_id ." ";
$query .= "LIMIT 1";
$result_set = mysql_query($query, $connection);
confirm_query($result_set);
// REMEMBER:
// if no rows are returned, fetch_array will return false
if ($subject = mysql_fetch_array($result_set)) {
return $subject;
} else {
return NULL;
}
}
function get_page_by_id($page_id) {
global $connection;
$query = "SELECT * ";
$query .= "FROM pages ";
$query .= "WHERE subject_id=" . $page_id ." ";
$query .= "LIMIT 1";
$result_set = mysql_query($query, $connection);
confirm_query($result_set);
// REMEMBER:
// if no rows are returned, fetch_array will return false
if ($page = mysql_fetch_array($result_set)) {
return $page;
} else {
return NULL;
}
}
function find_selected_page () {
global $sel_subject;
global $sel_page;
if (isset($_GET['subj'])) {
$sel_subject = get_subject_by_id($_GET['subject']);
$sel_page = NULL;
} elseif (isset($_GET['page'])) {
$sel_subject = NULL;
$sel_page = get_page_by_id($_GET['page']);
} else {
$sel_subject = NULL;
$sel_page = NULL;
}
}
function navigation($sel_subject = null, $sel_page = null) {
$subject_set = get_all_subjects();
// 5. Use returned data
while ($subject = mysql_fetch_array($subject_set)) {
echo "<div class="menu-name">"; echo "<a href="edit_subject.php?page=" . urlencode($subject["id"]) .
"">{$subject["menu_name"]}</a>"; echo"</div>";
echo "<div class="buying-text">"; echo "{$subject["content"]}"; echo"</div>";
echo "<div class="image">"; echo"</div>";
}
}
Thanks
No comments posted yet
Your Answer:
Login to answer
197
49
Other forums
PHP Surveys
I really would like some advice.
If you have a client come to you asking for a survey to be d
Problems with strings containing
Hey all,
I have encountered something strange in a script. I am trying to write an XML heade
parameter passing issue on function
Well I thought I had created a pretty slick web page, using ?page and $_GET to load pages which wher
how do i make new line after *
First check this page here. and you see my report. Im pulling form a mysql db. I want to beable to m
ALV List Display to point to another report on Double Click
Hi,
I want my ALV List Display to point to another report on Double Click on its line ite
At max how many columns is advisable to create in a table/view
Hi All,
I have two transaction table from which i want to create a simple view or material
small inaccuracies
I have this code to convert fractional base 10 into base 2:
while($num > 0)
Mail functionality from localhost to server
Hi
I am facing problem of mail functionality.
When i tested mail functionality in my
php problem?
I don't think I'm stupid, but maybe I am.
I am working on a sit for a friend I am try to put
urldecode question
How would I format this line of code properly?
<?php echo urldecode($_GET['Title']); ?