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/xmlrpc class issue
I am working on xml-rpc in php to start with.
I have a class that only has variables defined
php mail form text wont appear / javascript included
Guys/gals...
I am running into a problem whereby I have a great piece of javascript code that
Referential Integrity problem when inserting into 2 tables at same time
Hello Everyone,
Im relativity new to PHP and MySQL and i have come up against a problem. i h
EXplanation help
Hey all,
I am still fairly new to PHP programming and I am trying to put together a page wher
Batch Related Pricing
Hi, I need some clarity on the batch related pricing
For example the following are the b
Scrolling news bar and MySQL
I am not sure if this is the correct forum to post this on. If not, I apologize. I am still pretty
Redirect not working after making a POST/GET
Hi Everyone,
I am a novice in PHP. Here I have 2 pages, one page with a textbox and button an
Remove letter from numeric textbox
I have a textbox that will search the employee database by entering in the employee ID and it will r
problem with php server update from mid 2009
Hi,
I have this navigation menu on 2 websites which used to work just fine. After a recent up
mysql UNION | warning mysql_fetch_array !!
Code: <?php
$i = 0;
$query1="SELECT * FROM `products` WHERE `div