weaksauce Posted July 6, 2006 Share Posted July 6, 2006 If anyone could provide me some help, it would be much appreciated. I'd imagine this will require the most basic of answers, and even then it will undoubtedly be over my head. Anyway...I've put together a database table of schools. My repeating table on the page currently displays the school_name, school_city, and school_state. There is another column in my table, school_link, that contains a url to a page outside my site. I'd like to have the school_name display, but have it serve as the link to that external page. Since each link for each school is different, it's not as easy as just assigning an href to that particular spot where the school_name is set to appear.This is what I've tried (for my Alabama schools page):<a href="<?php echo $school_link; ?>"><?php echo $row_rsAlabama['school_name']; ?>And this is my currently defined recordset:$query_rsAlabama = "SELECT school_name, school_city, school_link, school_state FROM schools_tbl WHERE school_state = 'AL' AND school_active = '1' ORDER BY school_city ASC";This obviously doesn't work, but I thought I'd let whoever was considering helping me know where I'm starting from in terms of help needed. I would appreciate ANY guidance I could get in this matter. Thanks for taking the time to read my super long and boring first post. Quote Link to comment Share on other sites More sharing options...
CheesierAngel Posted July 6, 2006 Share Posted July 6, 2006 A solution can be:[code]<?php // ORDER BY ... ASC =:> ASC is the mysql default so it's not needed to mention $query = <<<SQL SELECT school_name, school_link FROM schools_tbl WHERE school_state = 'AL' AND school_active = '1' ORDER BY school_citySQL; $results = mysql_query($query); while($result = mysql_fetch_object($results) { $output .= "<a href='{$result->school_link}'>{$result->school_name}</a><br>"; } echo $output;?>[/code]This will output all school names as a link on a new line.Hope this helps you out. Quote Link to comment 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.