deansaddigh Posted February 14, 2010 Share Posted February 14, 2010 i have this piece of code and its wrong (obviously) Just trying to pass the school id across to the school_details.php page. echo "<a href='school_details.php?id=.'$school_id'.'>link to page2</a>"; Can someone show me what im doing wrong please Link to comment https://forums.phpfreaks.com/topic/192068-passing-a-variable-across-a-page/ Share on other sites More sharing options...
jl5501 Posted February 14, 2010 Share Posted February 14, 2010 try echo '<a href="school_details.php?id='.$school_id.'">link to page2</a>'; Link to comment https://forums.phpfreaks.com/topic/192068-passing-a-variable-across-a-page/#findComment-1012305 Share on other sites More sharing options...
deansaddigh Posted February 14, 2010 Author Share Posted February 14, 2010 Thanks for that. For somereason it saying variable undifined I have this sql statment which gets the school id <?php $query = "SELECT course.course_id, course.name AS course_name, course.level, course.price, course.duration, course.info, school.school_id, school.name AS school_name, school.street, school.town, school.city, school.county, school.region, school.postcode, school.country, school.school_facts, school.general_info, school.school_facilities FROM school_course JOIN course ON school_course.course_id = course.course_id JOIN school ON school_course.school_id = school.school_id"; //Use this query below $result = mysql_query($query, $conn) or die ("Unable to perform query: " . mysql_error()); //get school id $school_id = $row['school.school_id']; Is there something wrong with this line: $school_id = $row['school.school_id']; [/code] Link to comment https://forums.phpfreaks.com/topic/192068-passing-a-variable-across-a-page/#findComment-1012321 Share on other sites More sharing options...
sader Posted February 14, 2010 Share Posted February 14, 2010 variables that u send via url to another page are stored in super global array $_GET. so if u send school id like jl5501 sayd echo '<a href="school_details.php?id='.$school_id.'">link to page2</a>'; then school_details.php could look like this: <?php $school_id = $_GET['id']; //connection mysql_query("SELECT * FROM schools WHERE id=$school_id LIMIT 1"); ?> Link to comment https://forums.phpfreaks.com/topic/192068-passing-a-variable-across-a-page/#findComment-1012324 Share on other sites More sharing options...
jl5501 Posted February 14, 2010 Share Posted February 14, 2010 try $school_id = $row['school_id']; failing that, do this in the query ...... course.price, course.duration, course.info, school.school_id as school_id, schoo..... Link to comment https://forums.phpfreaks.com/topic/192068-passing-a-variable-across-a-page/#findComment-1012327 Share on other sites More sharing options...
deansaddigh Posted February 14, 2010 Author Share Posted February 14, 2010 Thanks man, it worked much appreciated. Link to comment https://forums.phpfreaks.com/topic/192068-passing-a-variable-across-a-page/#findComment-1012332 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.