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
197
49
Other php-forum
PHP code needed to get/post form fields and request mysql query results.
I'm new to PHP
I've created an html form to allow the user to request a basic telephone dire
how to easy edit text, with box? Help.
Hi.
I have a little problem. I'm doing a webpage for my aunt and I would like to make it as easy
Querying info from one table based on info in another
Hi, I am currently trying to make a part for my user driven website where one user can subscribe to
Pls help with PHP
Pls can anyone direct me on how to create a user account for a customer. For example i want know if
Google voice
I currently have a form in html, but I want it in php so the information is not in the source code.<
need good snippet manager
Hi. as i am coding and learning more, it is becoming difficult to manage code snippets. how you mana
convert static html data into dynamic
hi all
i need to convert a website which has static above 2000 articles into dynamic and add
IMAGE - SERVER SIDE scripting help...
How to receive pixel data of an image and buid a bitmap file on the server using the HTTP POST metho
need help with php get
i have a option box that gets filled with dates, but how do i get once the option value has been cli
Is this possible? If one file assigned to an ID...
I have a page that lists property listings assigned to a specific user (a manage page), with brief t