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 Like 49 Dislike
Previous forums Next forums
Other forums

update sql when refresh - php
hi
I have made a table (attachement)

the users can update the sql database using + or x bu

small inaccuracies
I have this code to convert fractional base 10 into base 2:

while($num > 0)

On page view, minus credit
Hello all, please, I need a little help with this script. I am charging one credit (credits can be p

question about header() security
is is safe to just use the header() function to redirect someone if they are, say, not logged in? or

Ajax Issues - Update Panel / Timer. Intellisense doesn't know about them
Type 'System.Web.UI.ScriptManager' does not have a public property named 'UpdatePanel'. That is wha

Procedural to OOP
John Kleijn said that to avoid writing "crappy code", we should learn OOP and common OO pr

C++ Http request?
Code: string Response = "LOGIN_UNSUCCESSFUL"; System.Net.WebRequest request = Sy

Links not updating
I'm trying to fuel a simple navigation system for a news section. It works fine when it comes to ret

How to use php and sql to check if values match the ones in a table (for logins)
How would I code it that the script takes two variables that are passed to it (UserID and PIN), and

IS Retail & Manufacturing
Hi

Can IS Retail and Manufacturing activities be done in same instance ie. in same client

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash