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
Did you know?Explore Trending and Topic pages for more stories like this.

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

Connect to database that isn't localhost
I am currently doing a small script for a company that doesn't have mySql support on there hosting.

IP Logger for Voting Script
Can anybody help me place an IP logger into my voting script?
I know that maybe it is not as secu

Unique Visitor Tracking
Hello. Currently, I run a voting site where voters are tracked by their IP address and can only vote

Problem with variable declaration in switch statement
Hello, I am having some trouble assigning a value to a variable inside a switch statement. What I a

problem when runing a funciton
I am trying to connect to database using a funciton in a functions.php

<?php
funct

Multidimensional $_POST
Hello

How to get a single array from array of array (2 - dimension).
For example I have a

How to copy a part of a vector in a raw memory
Hi,

How can I copy a part of a vector into a memory:

1
2
3
4
5

Session variable help
I'm having a very troubling issue. Maybe I'm just looking over something but I have looked at the co

PHP and SMS
Hi all forum members. I am new here and am unsure what category shoild I post this in.
Moderator

IIS7 and getimagesize() problem
I have just discovered after hrs of trying to fix a problem where it's coming from. It's to do with

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