jobs1109 Posted August 16, 2011 Share Posted August 16, 2011 Hi Everyone, I am trying to send a row of data to a page depending on which row is clicked Here is the code I have so far. <?php session_start(); ?> // Post variables <?php $_SESSION['Keyword_Search'] = $_POST['Keyword_Search']; $_SESSION['Jobcategory'] = $_POST['Jobcategory']; $Keyword_Search = $_SESSION['Keyword_Search']; $Jobcategory = $_SESSION['Jobcategory']; // echo $Keyword_Search; // echo $Jobcategory; ?> <?php include'../../DB-connect-here/DB-connetingtodatabase.php'; $Keyword_Search = $_SESSION['Keyword_Search']; $Jobcategory = $_SESSION['Jobcategory']; // echo $Keyword_Search; // echo $Jobcategory; ?> <br> <br> <br> <?php // getting data from table "Jobs-Table" $query = "SELECT * FROM Jobs-Table"; $result = mysql_query(" SELECT `id`, `JobTitle`, `Company`, `Salary`, `Description`, `CompanyURL`, `PhoneNumber`, `Requirements`, `JobCategory`, `JobType`, `Apply_To`, `Email`, `State`, `Address`, `Country`, `Zipcode` FROM `Jobs` ORDER BY id ASC") or die(mysql_error());while ($row = mysql_fetch_array($result)) { <?php echo 'Title: <a href="Job-Details.php?id=<?php echo $row['id']; ?>">'.$row['JobTitle'].'</a><br />'; }?> here is the error message I am getting Parse error: syntax error, unexpected '<'Getting-Data-Database6.php on line 50 here is line 50 <?php echo 'Title: <a href="Job-Details.php?id=<?php echo $row['id']; ?>">'.$row['JobTitle'].'</a><br />'; What am I doing wrong ? Thanks DS Quote Link to comment https://forums.phpfreaks.com/topic/244917-dynamic-link-php-and-mysql/ Share on other sites More sharing options...
ukscotth Posted August 16, 2011 Share Posted August 16, 2011 maybe change to this : <?php echo 'Title: <a href="Job-Details.php?id='.$row['id'].'">'.$row['JobTitle'].'</a><br />'; Quote Link to comment https://forums.phpfreaks.com/topic/244917-dynamic-link-php-and-mysql/#findComment-1258092 Share on other sites More sharing options...
AyKay47 Posted August 16, 2011 Share Posted August 16, 2011 few things here.. 1. why do you define $Keyword_Search and $Jobcategory to the same values twice..? 2. Why do you define $query without using it..? 3. As the color code tells you, this is a concatenation issue.. change to <?php echo "Title: <a href=\"Job-Details.php?id=<?php echo {$row['id']}; ?>\">{$row['JobTitle']}</a><br />"; Quote Link to comment https://forums.phpfreaks.com/topic/244917-dynamic-link-php-and-mysql/#findComment-1258101 Share on other sites More sharing options...
jobs1109 Posted August 16, 2011 Author Share Posted August 16, 2011 if I echo out the id I get all the id numbers. <?php // getting data from table "Jobs-table" $query = "SELECT * FROM Jobs-table"; $result = mysql_query(" SELECT `id`, `JobTitle`, `Company`, `Salary`, `Description`, `CompanyURL`, `PhoneNumber`, `Requirements`, `JobCategory`, `JobType`, `Apply_To`, `Email`, `State`, `Address`, `Country`, `Zipcode` FROM `Jobs-table` ORDER BY id ASC") or die(mysql_error());while ($row = mysql_fetch_array($result)) { echo "<br>Job ID: ".$row['id']; } ?> I get back Job ID: 39 Job ID: 40 Job ID: 41 Job ID: 42 Job ID: 43 Quote Link to comment https://forums.phpfreaks.com/topic/244917-dynamic-link-php-and-mysql/#findComment-1258107 Share on other sites More sharing options...
AyKay47 Posted August 16, 2011 Share Posted August 16, 2011 isn't that what you want.. also I made a mistake in the anchor tag above.. should be.. echo "Title: <a href=\"Job-Details.php?id={$row['id']}\">{$row['JobTitle']}</a><br />"; Quote Link to comment https://forums.phpfreaks.com/topic/244917-dynamic-link-php-and-mysql/#findComment-1258110 Share on other sites More sharing options...
jobs1109 Posted August 16, 2011 Author Share Posted August 16, 2011 here is the code I have now <?php session_start(); ?> // Post variables <?php include'../../DB-connection/DB-connect.php'; $_SESSION['Keyword_Search'] = $_POST['Keyword_Search']; $_SESSION['Jobcategory'] = $_POST['Jobcategory']; $Keyword_Search = $_SESSION['Keyword_Search']; $Jobcategory = $_SESSION['Jobcategory']; // echo $Keyword_Search; will be used in future // echo $Jobcategory; will be used in future ?> <br> <br> <br> <?php // getting data from table "Jobs-table" $query = "SELECT * FROM Jobs-table"; $result = mysql_query(" SELECT `id`, `JobTitle`, `Company`, `Salary`, `Description`, `CompanyURL`, `PhoneNumber`, `Requirements`, `JobCategory`, `JobType`, `Apply_To`, `Email`, `State`, `Address`, `Country`, `Zipcode` FROM `Jobs-table` ORDER BY id ASC") or die(mysql_error());while ($row = mysql_fetch_array($result)) { <?php echo "Title: <a href=\"Job-Details.php?id=<?php echo {$row['id']}; ?>\">{$row['JobTitle']}</a><br />"; } ?> if I echo 'title, Address, id etc I get back all the info but I am still getting the following error message Parse error: syntax error, unexpected '<' in /Getting-Data-Database7.php on line 43 here is the line 43 <?php echo "Title: <a href=\"Job-Details.php?id=<?php echo {$row['id']}; ?>\">{$row['JobTitle']}</a><br />"; I would like users to click on the title and go to the "Job-Details.php" page where the details will be desplayed for the job id link clicked. Quote Link to comment https://forums.phpfreaks.com/topic/244917-dynamic-link-php-and-mysql/#findComment-1258111 Share on other sites More sharing options...
AyKay47 Posted August 16, 2011 Share Posted August 16, 2011 right, change to the suggested anchor tag that I have provided above.. Quote Link to comment https://forums.phpfreaks.com/topic/244917-dynamic-link-php-and-mysql/#findComment-1258112 Share on other sites More sharing options...
jobs1109 Posted August 16, 2011 Author Share Posted August 16, 2011 Hi Thanks, here is what I have on the details page <?php $id = $_SESSION[`id`]; $query = "SELECT * FROM Jobs-table where id=$id"; $result = mysql_query(" SELECT `id`, `JobTitle`, `Company`, `Salary`, `Description`, `CompanyURL`, `PhoneNumber`, `Requirements`, `JobCategory`, `JobType`, `Apply_To`, `Email`, `State`, `Address`, `Country`, `Zipcode` FROM `Jobs-table` ORDER BY id ASC") or die(mysql_error()); $row = mysql_fetch_array($result); echo "ID: ".$row['id']; echo "<br>Job Title: ".$row['JobTitle']; echo "<br> Company: ".$row['Company']; echo " <br>Salary: ".$row['Salary']; echo "<br> Description: ".$row['Description']; echo "<br> Company-URL: ".$row['CompanyURL']; echo "<br> Phone-Number: ".$row['Phone-Number']; echo "<br> Address: ".$row['Address']; echo "<br> Requirements: ".$row['Requirements']; echo "<br> Job-Type: ".$row['JobType']; echo "<br> JobCategory: ".$row['JobCategory']; echo "<br><br><br><br><br>"; ?> now I get the same results for all the links. Quote Link to comment https://forums.phpfreaks.com/topic/244917-dynamic-link-php-and-mysql/#findComment-1258121 Share on other sites More sharing options...
AyKay47 Posted August 16, 2011 Share Posted August 16, 2011 1. you are using backticks " ` " in your index when you should be using quotes... like this $id = $_SESSION[`id`]; //wrong way $id = $_SESSION['id']; //right way 2. If you are expecting more than one row to be grabbed from your query... place your code in a while loop.. while($row = mysql_fetch_array($result)){ echo "ID: ".$row['id']; echo "<br>Job Title: ".$row['JobTitle']; echo "<br> Company: ".$row['Company']; echo " <br>Salary: ".$row['Salary']; echo "<br> Description: ".$row['Description']; echo "<br> Company-URL: ".$row['CompanyURL']; echo "<br> Phone-Number: ".$row['Phone-Number']; echo "<br> Address: ".$row['Address'];echo "<br> Requirements: ".$row['Requirements']; echo "<br> Job-Type: ".$row['JobType']; echo "<br> JobCategory: ".$row['JobCategory']; echo "<br><br><br><br><br>"; } Quote Link to comment https://forums.phpfreaks.com/topic/244917-dynamic-link-php-and-mysql/#findComment-1258125 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.