Hello I am trying to understand why this isn't working on my page. I am using the php block below to use the variable I created at the beginning of my page $sel_subj (I used $_GET to get the id of what I clicked on on the previous page. I want the new page to reflect the data of the link I clicked on) I got the url to work to show the correct number from the database but I cannot get my page to display the name of what link was pressed; aka the data in the column labeled 'subject_name' from the 'subjects' table.
<?php
$query = "SELECT * FROM subjects WHERE id = \"$sel_subj\"";
$result_set = mysql_query($query, $connection);
if(!$result_set) {
die("Database query failed: " . mysql_error());
$subject = mysql_fetch_array($result_set);
return $subject;
?>
into this h2 tag right here.
<h2><?php echo $subject['subject_name']; ?>Hello</h2>
I can post the whole page if it will help. I appreciate everyone's input.
Thank you.
edit:new problems
Here is the bottom half of my code. I have a navigation div above this code which separates the links to the pages that relate to the database tables from the content that I'd like to pull from the db and display in the div for the page table.
However with the code I've provided nothing is showing up on the page when I open it in firefox. In my html when I "view source" while previewing on the testing server there is nothing underneath ...
<td id="page">
<?php
$query = "SELECT * FROM subjects WHERE id ='$sel_subj'";
$result_set = mysql_query($query, $connection);
if(!$result_set)
die("Database query failed: " . mysql_error());
$subject = mysql_fetch_assoc($result_set);
return $subject;
?>
<h2><?php echo $subject['subject_name']; ?>Hello</h2>
<br />
<?php echo $sel_page; ?><br />
<?php echo $sel_subj; ?><br />
<?php echo $subject; ?><br />
<?php echo $subject['id']; ?>
</td>
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1if I add LIMIT 1 to the sql query the error changes, saying :near 'LIMIT 1' at line 1at the end of the error instead..."SELECT * FROM subjects WHERE id ={$sel_subj} LIMIT 1";