PHP - Links Of Titles When Clicked Show Title & Description Of Item Being Clicked.
I feel like a moron asking this question as it seems to be one of the most common things done with php but I cannot find a tutorial (probably because I don't know the correct wording to search under) on this specific thing..
Anyhow. I'm spitting out a list of the Titles of my test table like so (and its working as expected): <?php $posting_sql = "SELECT * FROM postings"; $posting_results = (mysqli_query($cxn, $posting_sql)) or die("Was not able to grab the Postings!"); while($posting_row = mysqli_fetch_array($posting_results)) { echo "<li><a href='posting_details.php'>$posting_row[title]</a></li>"; } ?> Now as you can see: <a href='posting_details.php'> I am calling a new page, and that page contains this: <h2><?php echo "$posting_row[title]"; ?></h2> <p><?php echo "$posting_row[description]"; ?></p> It's no surprise it's not working (with many variations etc), but I am only familiar with using <form> GET or POST, and these of course are not form elements, so I cant seem to call them the same way. My suspicion (and from the research data I could find) is that I need to pass values in my link: <a href='posting_details.php'> ... I could not get it to work, but I was trying variations like: <a href='posting_details.php?get[title&get[description]]'> but it seems like I am screwing things up even more by doing this.. Anyhow. If anyone could show me a tutorial that covers this specifically or some suggestions on the best approach to this would be much appreciated.. Similar Tutorialshi, at the moment, my page only works with the County: Angus (2nd in the list) List of Counties County List Angus County List The code for my Pubs page is below..., I think I need to change the hard coded bit that reads: Code: [Select] echo "<ul title=\"Pubs in Angus\" id=\"Angu\">"; and the SQL string: Code: [Select] $query = "SELECT * FROM pubs WHERE rsCounty = 'Angus' LIMIT $offset, $rowsPerPage"; pubs page Code: [Select] <?php include_once("config.php"); include_once("functions.php"); // Check user logged in already: checkLoggedIn("no"); //doCSS(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>My Pub Space</title> <link rel="stylesheet" type="text/css" href="stylesheets/style1.css" title="default" /> <meta name="viewport" content="width=device-width; initial-scale=1.0; minimum-scale=1.0; maximum-scale=1.0; user-scalable=0;"/> <link rel="apple-touch-icon" href="../iui/iui/mps-icon.png" /> <style type="text/css" media="screen">@import "../iui/iui/iui.css";</style> <script type="application/x-javascript" src="../iui/iui/iui.js"></script> <meta name="apple-touch-fullscreen" content="YES" /> <script type="text/javascript" src="js/jva.js"></script> </head> <body> <? $offset = (isset($_GET['start'])) ? (int)$_GET["start"] : 0; $rowsPerPage = (isset($_GET['count'])) ? (int)$_GET["count"] : 10; $query = "SELECT * FROM pubs WHERE rsCounty = 'Angus' LIMIT $offset, $rowsPerPage"; $result = mysql_query($query) or die(mysql_error().'<br>SQL: ' . $query); //looping counties $query1 = "SELECT rsCounty, COUNT(PUBID) AS County_Count FROM pubs GROUP BY rsCounty"; $result1 = mysql_query($query1) or die(mysql_error().'<br>SQL: ' . $query1); $County1 = $result1['rsCounty']; $CountyCount = $result1['County_Count']; ?> <div class="toolbar"> <h1 id="pageTitle">Select County</h1> <a id="backButton" class="button" href="#"></a> <a class="button" href="logout.php" target="_self">Logout</a> </div> <ul title="Select County" id="county" selected="true"> <?php while ($row = mysql_fetch_assoc($result1)){ $RSCOUNTY1 = $row['rsCounty']; $RSCOUNTY1short = substr($row['rsCounty'],0,4); $CountyCount = $row['County_Count']; echo <<<EOF <li><a href="#$RSCOUNTY1" class="digg-count">$CountyCount</a> <a href="#$RSCOUNTY1short">$RSCOUNTY1</a></li> EOF; } echo "</ul>"; // start East Sussex echo "<ul title=\"Pubs in Angus\" id=\"Angu\">"; while($row = mysql_fetch_array($result)){ $PUBID = $row['PUBID']; $rsPubName = $row['rsPubName']; $rsAddress = $row['rsAddress']; $rsPostCode = $row['rsPostCode']; $rsTel = $row['rsTel']; $rsTown = $row['rsTown']; $rsCounty = $row['rsCounty']; // how many rows we have in database // print the link to access each page $self = $_SERVER['PHP_SELF']; $next = "<li><a href=\"all.php?start=" . ($offset + $rowsPerPage) . "&count={$rowsPerPage}\" target=\"_replace\">View More</a></li>"; //div container of header and information echo <<<EOF <li><a href="viewpub.php?PUBID=$PUBID">$rsPubName</a></li> EOF; if ($_SESSION["RSUSER"] == "admin") { echo "<a href=\"edit.php?PUBID=$PUBID\" class=\"small\">edit this pub</a>"; } } echo $next; echo "</ul>"; // End East Sussex ?> </body> </html> Please help?! Hi I am trying to pull title and meta description from an URL.. To pull the URL I am using the code from http://www.dreamincode.net/code/snippet4625.htm... function getTitle($Url){ $str = file_get_contents($Url); if(strlen($str)>0){ preg_match("/\<title\>(.*)\<\/title\>/",$str,$title); return $title[1]; } } //Example: echo getTitle("http://www.cnn.com"); And to pull the meta description I am using the code from http://php.net/manual/en/function.get-meta-tags.php. // Assuming the above tags are at www.example.com $tags = get_meta_tags('http://www.cnn.com/') or die("Could not fetch meta tags"); // Notice how the keys are all lowercase now, and // how . was replaced by _ in the key. echo $tags['author']; // name echo $tags['keywords']; // php documentation echo $tags['description']; // a php manual echo $tags['geo_position']; // 49.33;-86.59 So my complete code looks like this: <html> <head> </head> <body> <?php function getTitle($Url){ $str = file_get_contents($Url); if(strlen($str)>0){ preg_match("/\<title\>(.*)\<\/title\>/",$str,$title); return $title[1]; } } //Example: echo getTitle("http://www.cnn.com"); // Assuming the above tags are at www.example.com $tags = get_meta_tags('http://www.cnn.com/') or die("Could not fetch meta tags"); // Notice how the keys are all lowercase now, and // how . was replaced by _ in the key. echo $tags['author']; // name echo $tags['keywords']; // php documentation echo $tags['description']; // a php manual echo $tags['geo_position']; // 49.33;-86.59 ?> Test! </body> </html> But it wont work... All I get is "Could not fetch meta tags".. I've tried different URLs and such but still wont work .. Anyone have an idea? On the index page of http://www.sportskevesti.co i have the meta tags of Title, Description, Keyword.... and other element, but it is necessary to show them in name of the other pages, socer, basketbal, handbal, tennis...., and there fore news spetial. in this moment, i have this meta tag double. for example: www.sportskevesti.co/index.php Quote <meta name="title" content="Sportske Vesti"> <meta name="description" content="Najnovije sportske vesti iz Srbije i ostatka sveta. Sve na jednom mestu."> <meta name="keywords" content="sport, vesti, fudbal, tenis, kosarka, odbojka, rukomet, auto, moto, trke"> http://sportskevesti.co/index.php?opcija=vest&vest_id=60067 Quote <meta name="title" content="Sportske Vesti"> <meta name="description" content="Najnovije sportske vesti iz Srbije i ostatka sveta. Sve na jednom mestu."> <meta name="keywords" content="sport, vesti, fudbal, tenis, kosarka, odbojka, rukomet, auto, moto, trke"> <meta name="title" content="Danas je derbi!" /> <meta name="description" content="Na stadionu Crvene zvezde danas se igra ..." /> <meta name="keywords" content="danas, derbi, "/> Since I assume that this is not good for SEO optimization, how to avoid this and show only one meta per page ? Hi all, I wonder if anyone could give me some idea: I have a form and one of the filed is an email (must field) if empty an error message will show up: - Now I want to add a CHECKBOX where when the CHECKBPX is clicked the "must field" email will become" not must field one" (Not required field). I have this code as my snippets: Code: [Select] <form action="<?php echo $PHP_SELF;?>" method="post" name="reg1"> .. <tr> <td><input name="noemail" type="checkbox" value="noemail"> Do not want to get the E-mail address</td> </tr> <tr> <td nowrap>Enter email <input name="email1" type="text" <?php if ($_POST['action'] == "register") { echo 'value="'.$_POST['email1'].'"'; } ?>> </td> </tr> .. </form> .. .. $error = 0; $errormsg = ""; .. .. if ($_POST['action'] == "register") { if (($_POST['email1'] == "") OR (!check_text($_POST['email1']))) { $error = 1; $errormsg .= "Please enter your requested email address<br>"; $errornum[3] = 1; } } .. Can anyone assist me what shall I add so I can achieve this please? Thanks in advance. Siabanie I have a page that reads from a database to list employees from different states. Under each name is a link that pulls up a new window with a contact form. My goal is to get the name from that link to appear on that new window. (Which I will then use to ultimately add the name into the email that was generated so the recipient can know who the email was intended for.) I've tried using the GET and POST methods but nothing seems to work. Any help would be appreciated greatly. I will name my firstborn after anything you desire. I've included my code below. (The last line is what I've been primarily working with) Code: [Select] //Open Database Connection $db = open_db_connection(); $sql = "SELECT DISTINCT 1 from users where active = 'Y' and show_on_contactus = 'Y'"; $results = mysql_query($sql, $db); $emaillink = "<a target='main' onclick=window.open('contactform/contactCentral.php?name=$state_row[state]','popup','width=380,height=400,scrollbars=no,resizable=no,toolbar=yes,directories=no,location=no,menubar=yes,status=no,left=0,top=0'); return false>"; if(!mysql_num_rows($results) == FALSE) while($row = mysql_fetch_array($results, MYSQL_BOTH)) { echo "<ul id=\"directors\">\n"; $state_sql = "SELECT * from users where active = 'Y' and show_on_contactus = 'Y' and state_full = 'indiana' order by last_name"; $state_results = mysql_query($state_sql, $db); if(!mysql_num_rows($results) == FALSE) { while($state_row = mysql_fetch_array($state_results, MYSQL_BOTH)) { echo "<li>\n"; echo " <div class=\"fl dirimg\">\n"; if($state_row[photo] == "") { echo "<img border=\"0\" width=\"61\" height=\"85\" src=\"images/exe_placeholder.jpg\" alt=\"$state_row[first_name] $state_row[last_name]\" />\n"; } else { echo "<img border=\"0\" width=\"61\" height=\"85\" src=\"n2team/pictures/$state_row[photo]\" alt=\"$state_row[firstname] $state_row[last_name]\" />\n"; } echo " </div>\n"; echo " <span class=\"fr\">$state_row[first_name] $state_row[last_name]<br />\n"; echo " $state_row[title]<br />\n"; echo " $state_row[city], $state_row[state]<br />\n"; echo " $emaillink Contact $state_row[first_name] </a></span></li>\n"; } Hello, I had a web page which had sharing (share issue on facebook, twitter....) and I want to record what each user had shared. So, they will click on alink to share it. I want to call a php function when the user click on a link, whats the best method to do this? Thanks in advance Hi, I need to make it so the items on my page are only displayed if the value in their database column is set to 1 (and 0 for no display). And I should be able to change those values with a checkbox toggle on my admin panel. Ideally I wouldn't have to click submit either. Table: <table id="datatables" class="table table-striped table-no-bordered table-hover" cellspacing="0" width="100%" style="width:100%"> <thead> <tr> <th>ID</th> <th>Item name</th> <th>Item group</th> <th>Actions</th> <th>Display</th> </tr> </thead> <tbody> <?php if($result -> num_rows > 0){ while($row = $result-> fetch_assoc()){ echo "<tr>"; echo "<td>" . $row["id"] ."</td>"; echo "<td>" . $row["item_name"]. "</td>"; echo "<td>" . $row["group_name"] ."</td>"; ?> <?php require_once "deleteitem.php"; ?> <td> <a href="edititem.php?edit=<?php echo $row['id']; ?>" name="edit"><i class="material-icons">edit</i></a> <a href="?delete=<?php echo $row['id']; ?>" name="delete"><i class="material-icons">delete</i></a> </td> <td> <form action="displayitem.php" method="POST"> <div class="togglebutton"> <label> <input type="checkbox" name="display"> <span class="toggle"></span> </label> </div> </form> </td> <?php echo "</tr>"; } } ?> </tbody> </table> https://i.imgur.com/Qyz6s8v.png In displayitem.php <?php if(isset($_POST['display'])){ echo '<p>'.$_POST['display'].'</p>'; // queries etc here } ?> I'm not getting the value here unless I add a submit button. Guessing jQuery / AJAX is the way to go but can't seem to find any good tutorials on it, are there any other suitable approaches to this?
I'm currently creating a web based application for the company I'm working on. It was just a simple application that I can surely done but there is one thing that become a hindrance... That thing is the situation wherein dialog box that keeps on popping whenever I clicked the submit button wherein supposed to be it should change page. Hope everyone could help. Thank you in advance. This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=317810.0 Hi I was thinkin that I wanna make a simulor function to the one they use on betting site... User sees Team1 vs Team2 When he clicks "team2" it gets registered somewhere before he clicks "bet" wich inserts all his bets somewhere. Hi I'm trying to create a page where there is a grid of images and if you click on one of those images it will expand. Once the image has expanded and you click on the i icon that is below it, the i icon will display the information about that image. This isn't like a popup or anything like that, because when you click on the image and it expands, it expands in the same spot and it doesn't popup. Here is the html $str.='<div class="portfolio-banner-wrapper'.$langClass.'" style="position: relative;">'; $str.= '<a class="portfolio-arrow-left'.$langClass.' portfolio-navigate'.$langClass.'" href="javascript:void(0);"><img src="images/left-arrow.png" onmouseover="this.src=\'images/blue-left-arrow.png\'" onmouseout="this.src=\'images/left-arrow.png\'" /></a>'; $str.= '<a class="portfolio-arrow-right'.$langClass.' portfolio-navigate'.$langClass.'" href="javascript:void(0);"><img src="images/right-arrow.png" onmouseover="this.src=\'images/blue-right-arrow.png\'" onmouseout="this.src=\'images/right-arrow.png\'"/></a>'; $str.= '<div class="portfolio-banner-inner">'; $str.= $this->getPortfolioTest(); $str.= '</div>'; $str.='</div>'; $str.='<div class="overlay-bg'.$langClass.'">'; $str.= '<div class="additional-navigation-wrapper'.$langClass.'">'; $str.= '<div class="info'.$langClass.'" style="display: none;">'; $str.= '<a class="border-bottom-white padding-level-one inactive additional-nav-info1" href="javascript:void(0);">'; $str.= '<img class="icon" src="images/i_icon.png" />'; $str.= '<img class="nav-arrow no-action floatright" src="images/nav-arrow-white.png" />'; $str.= '<span class="clearboth"></span>'; $str.= '</a>'; $str.= '<div class="additional-nav-info-wrapper1">'; $str.= $this->i_icon(); $str.= '</div>'; $str.= '</div>'; $str.= '</div>';Here is the php function getPortfolioTest(){ global $_PRODUCTS_TABLE, $_HTTP_ADDRESS, $_PRODUCTS_IMAGES_DIR; $i=0; $cpt = 1; $str = ''; $whichCount = 1; $jobSearch=''; $query = mysql_query("SELECT * FROM $_PRODUCTS_TABLE WHERE `active`='1' AND `image` LIKE '%.%'".$jobSearch." ORDER BY `client` ASC"); $combineArr = mysql_num_rows($query); while( $result = mysql_fetch_object($query) ){ $product = new Product($result->id); $product->setFromDatabase(); $linkOut = getSEOLink($product->id); $target = ""; if(trim($product->linkout) != ""){ $linkOut = $product->linkout; $target = ' target="_blank"'; } if($whichCount == 1){ $portfolioClass="portfolio-active"; $style = "position: absolute; left:0%; top:0; width:100%;"; }else{ $portfolioClass="portfolio-inactive"; $style = "position: absolute; left:-100%; top:0; width:100%;"; } if($whichCount == 1){ $str.='<div id="portfolio-slide'.$i.'" class="portfolio-slide '.$portfolioClass.'" style="'.$style.'">'; $str.= '<div class="portfolio-slide-inner">'; $str.= '<div class="portfolio-banner-content portfolio-banner-left">'; $str.= '<div class="portfolio-banner-header">'; $str.= '</div>'; $str.= '<div class="portfolio-banner-copy">'; $str.= '<ul id="gallery">'; } $str.= '<li>'; $str.= '<a'.$target.' href="javascript:void(0);">'; $str.= '<img src="'.$_HTTP_ADDRESS.'products_images/'.$result->image.'">'; echo "this is getPortfolioTest"; $str.= '</a>'; $str.= '<span>'; $str.= '<h3>'.$result->name.'</h3>'; $str.= $result->description; $str.= '</span>'; $str.= '</li>'; if($whichCount % 9 == 0 && $whichCount < $combineArr){ $i++; $str.= '<div class="clearboth"></div>'; $str.= '</ul>'; $str.= '</div>'; $str.= '</div>'; $str.= '</div>'; $str.='</div>'; $str.='<div id="portfolio-slide'.$i.'" class="portfolio-slide '.$portfolioClass.'" style="'.$style.'">'; $str.= '<div class="portfolio-slide-inner">'; $str.= '<div class="portfolio-banner-content portfolio-banner-left">'; $str.= '<div class="portfolio-banner-header">'; $str.= '</div>'; $str.= '<div class="portfolio-banner-copy">'; $str.= '<ul id="gallery">'; } if($whichCount == $combineArr){ $str.= '<div class="clearboth"></div>'; $str.= '</ul>'; $str.= '</div>'; $str.= '</div>'; $str.= '</div>'; $str.='</div>'; } $whichCount++; $cpt++; } return $str; } function i_icon(){ global $_PRODUCTS_TABLE, $_HTTP_ADDRESS, $_PRODUCTS_IMAGES_DIR; $str = ''; $i = 0; $query = mysql_query("SELECT * FROM $_PRODUCTS_TABLE WHERE `active`='1'"); while($result = mysql_fetch_object($query)){ $str.= '<div class="additional-nav-info-inner'.$i.' overlay-bg" style="display:none;">'; $str.= '<ul>'; $str.= '<h3>'.$result->name.'</h3>'; $str.= '<p>'; $str.= $result->overview; $str.= '</p>'; $str.= '</ul>'; $str.= '</div>'; $i++; } return $str; }Here is the Jquery function galleryInit(){ $('#gallery li').hover( function(){$('span',this).slideToggle('fast');}, function(){$('span',this).slideToggle('fast'); }); $(".portfolio-banner-inner li").click(function(e){ if($(".activeExpand").length > 0){ $(".portfolio-active").css({"left":"0%"}); $(".portfolio-active").prevAll().css({"left":"-100%"}); $(".portfolio-active").nextAll().css({"left":"100%"}); $(".portfolio-banner-inner li").removeClass("inactiveExpand").removeClass("activeExpand").removeAttr("style").find("img").removeAttr("style"); $(".portfolio-arrow-left-scroll").addClass("portfolio-arrow-left").removeClass("portfolio-arrow-left-scroll"); $(".portfolio-arrow-right-scroll").addClass("portfolio-arrow-right").removeClass("portfolio-arrow-right-scroll"); return false; } $this = $(this); $(".portfolio-banner-inner li").addClass("inactiveExpand") $this.removeClass("inactiveExpand").addClass("activeExpand"); $(".portfolio-slide").css({"left":"0"}) $this.parents(".portfolio-slide:first").prevAll().find(".portfolio-slide-inner li").css({"position":"absolute","width":"100%","height":"100%","top":"0","left":"-100%"}).find("img").css({"width":"952px","height":"502px"}); $this.parents(".portfolio-slide:first").nextAll().find(".portfolio-slide-inner li").css({"position":"absolute","width":"100%","height":"100%","top":"0","left":"100%"}).find("img").css({"width":"952px","height":"502px"}); $this.siblings().prevAll().css({"position":"absolute","width":"100%","height":"100%","top":"0","left":"-100%"}).find("img").css({"width":"952px","height":"502px"}); $this.siblings().nextAll().css({"position":"absolute","width":"100%","height":"100%","top":"0","left":"100%"}).find("img").css({"width":"952px","height":"502px"}); $this.css({"position":"absolute","width":"100%","height":"100%","top":"0","left":"0"}); $this.find("img").animate({ width: '952px',//what the width of the image to be expanded is height: '502px'//what the width of the image to be expanded is }, 200); $(".portfolio-arrow-left").addClass("portfolio-arrow-left-scroll").removeClass("portfolio-arrow-left"); $(".portfolio-arrow-right").addClass("portfolio-arrow-right-scroll").removeClass("portfolio-arrow-right"); }); } function imageSlider(direction){ $activeExpandWhere = $(".activeExpand"); if($(".activeExpand").css("left") != "0px") return false; if(direction == "right"){ $(".inactiveExpand").css({"left":"100%"}); $(".activeExpand").animate({"left":-100+"%"},500,"easeInCubic",function(){ $(this).removeClass("activeExpand").addClass("inactiveExpand"); }); if($(".activeExpand").next("li").length == 0){ if($activeExpandWhere.parents(".portfolio-slide:first").next().length == 0){ $(".portfolio-slide").removeClass("portfolio-active").addClass("portfolio-inactive"); $(".portfolio-slide:first").removeClass("portfolio-inactive").addClass("portfolio-active"); $(".portfolio-slide:first").find(".portfolio-slide-inner li").eq(0).animate({"left":0+"%"},500,"easeInCubic",function(){ $(this).removeClass("inactiveExpand").addClass("activeExpand"); }); return false; } $(".portfolio-slide").removeClass("portfolio-active").addClass("portfolio-inactive"); $activeExpandWhere.parents(".portfolio-slide:first").next().removeClass("portfolio-inactive").addClass("portfolio-active"); $activeExpandWhere.parents(".portfolio-slide:first").next().find(".portfolio-slide-inner li").eq(0).animate({"left":0+"%"},500,"easeInCubic",function(){ $(this).removeClass("inactiveExpand").addClass("activeExpand"); }); return false; } $(".activeExpand").next("li").animate({"left":0+"%"},500,"easeInCubic",function(){ $(this).removeClass("inactiveExpand").addClass("activeExpand"); }); return false; } $(".inactiveExpand").css({"left":"-100%"}); $(".activeExpand").animate({"left":100+"%"},500,"easeInCubic",function(){ $(this).removeClass("activeExpand").addClass("inactiveExpand"); }); if($(".activeExpand").prev("li").length == 0){ if($activeExpandWhere.parents(".portfolio-slide:first").prev().length == 0){ $(".portfolio-slide").removeClass("portfolio-active").addClass("portfolio-inactive"); $(".portfolio-slide:last").removeClass("portfolio-inactive").addClass("portfolio-active"); $(".portfolio-slide:last").find(".portfolio-slide-inner li").eq(($(".portfolio-slide:last").find(".portfolio-slide-inner li").length-1)).animate({"left":0+"%"},500,"easeInCubic",function(){ $(this).removeClass("inactiveExpand").addClass("activeExpand"); }); return false; } $(".portfolio-slide").removeClass("portfolio-active").addClass("portfolio-inactive"); $activeExpandWhere.parents(".portfolio-slide:first").prev().removeClass("portfolio-inactive").addClass("portfolio-active"); $activeExpandWhere.parents(".portfolio-slide:first").prev().find(".portfolio-slide-inner li").eq(0).animate({"left":0+"%"},500,"easeInCubic",function(){ $(this).removeClass("inactiveExpand").addClass("activeExpand"); }); return false; } $(".activeExpand").prev("li").animate({"left":0+"%"},500,"easeInCubic",function(){ $(this).removeClass("inactiveExpand").addClass("activeExpand"); }); } $(document).ready(function(e) { galleryInit(); $(".additional-nav-info1").click(function(){ if($(".additional-nav-info-inner1").css("display") == "block"){ $(this).removeClass("active"); $(this).addClass("inactive"); $(".additional-nav-info-inner1").stop().slideToggle(250); } else { $(this).removeClass("inactive"); $(this).addClass("active"); $(".additional-nav-info-inner1").stop().slideToggle(250); } }); $(".additional-nav-info-inner1 a").hover(function(){ $(this).find("img").eq(0).fadeOut(250); $(this).find("img").eq(1).fadeIn(250); }, function(){ $(this).find("img").eq(0).fadeIn(250); $(this).find("img").eq(1).fadeOut(250); }); } I have a "Members" page that displays my organizations members info via My SQL. Currently, the database displays "State" quick links at the top and has the members organized by State down the page. If you click on one of the State links at the top, it will navigate to the section of the page with that state and associated members. I want the members associated with a specific state to be displayed only once I click the associated state link -- instead of all of the information showing at once like it is now. The page I am referring to can be seen at this link: http://homesforhorse...rs.com/members/
<?php update_option('image_default_link_type','none'); include("/home/cingen/config_admin.php"); function listMembers() { $sql = mysql_query("SELECT c.*, s.* FROM (".TABLE_MEMBERS." c LEFT JOIN ".TABLE_STATE." s on c.state = s.state_abbr) WHERE c. status = '1' ORDER BY c.country, c.state, c.organization ASC"); while ($row = mysql_fetch_array($sql)) { $display_members = false; $organization = stripslashes($row['organization']); $website = stripslashes($row['website']); if ($website) { $link = "<a href='http://".$website."' target='_blank'>"; $endlink = "</a>"; } else { $link = ""; $endlink = ""; } $display_members .= $link.$organization.$endlink."<br />"; if ($row['address']) $display_members .= stripslashes($row['address'])." ".stripslashes($row['address2'])."<br />"; if ($row['city']) $display_members .= stripslashes($row['city']).", "; if ($row['state']) $display_members .= stripslashes($row['state']).""; if ($row['zip']) $display_members .= " ".$row['zip']; $display_members .= "<br />"; if ($row['contact_name']) $display_members .= "Contact: ".stripslashes($row['contact_name']); if ($row['contact_title']) $display_members .= ", ".stripslashes($row['contact_title']); if ($row['phone']) $display_members .= "<br />Tel: ".stripslashes($row['phone']); if ($row['email']) $display_members .= "<br />".$row['email']; if ($row['website']) $display_members .= "<br /><a href='http://".$row['website']."' target='_blank'>".$row['website']."</a><br/>"; if ($row['year_est']) $display_members .= "Founded in ".$row['year_est']."."; if ($row['org501c3'] == "1") $display_members .= " A 501(c)3 non-profit."; if ($row['gfas'] == "1") $display_members .= "<br />GFAS: Accredited Sanctuary."; if ($row['gfas'] == "2") $display_members .= "<br />GFAS: Verified Sanctuary."; if ($row['member_category']) $display_members .= "<br />".$row['member_category']; $display_members .= "<br /><br />"; $entries[$row['country']][$row['state_name']][] = $display_members; } $countrylinks = false; $statelinks = false; $display = false; if(is_array($entries)){ $display .= ' <div class="memberlist">'; foreach($entries as $country=>$state_members){ $countrylinks .= '<a href="#'.$country.'">'.$country.'</a> '; $display .= ' <h2 id="'.$country.'">'.strtoupper($country).'</h2> <div class="country">'; if(($state_members)){ foreach($state_members as $state=>$members){ $statelinks .= '<a href="#'.$state.'">'.$state.'</a> '; $display .= ' <h3 id="'.$state.'">'.strtoupper($state).'</h3> <div class="state">'; if(is_array($members)){ foreach($members as $key=>$member){ $display .= ' <div class="member"> '.$member.' </div>'; } } $display .= ' </div>'; } } $display .= ' </div>'; } $display .= ' </div>'; } $statelinks1 = ' <h2>Members List</h2> <strong>Quick Links</strong><br /><br /> '.$statelinks.'<br /><br />' .$display; return $statelinks1; } add_shortcode('memberlist', 'listMembers'); function listRescueStandards() { $display_members = ''; $sql = mysql_query("SELECT vc.*, s.*, m.* FROM ".TABLE_COMPLIANCE." vc, ".TABLE_STATE." s, ".TABLE_MEMBERS." m WHERE vc.member_id = m.cid AND m.status = '1' AND m.state = s.state_abbr ORDER BY m.state, m.organization ASC"); while ($row = mysql_fetch_array($sql)) { $organization = stripslashes($row['organization']); if ($row['website']) { $link = "<a href='http://".$row['website']."' target='_blank'>"; $endlink = "</a>"; } else { $link = ""; $endlink = ""; } if($x!=$row['state_name']){ $display_members .= "<br /><strong>".strtoupper($row['state_name'])."</strong><br />"; $x = $row['state_name']; } $display_members .= $link.$organization.$endlink."<br /> ".stripslashes($row['address'])." ".stripslashes($row['address2'])."<br /> ".stripslashes($row['city']).", ".stripslashes($row['state'])." ".$row['zip']."<br />"; if ($row['contact_name']) $display_members .= "Contact: ".stripslashes($row['contact_name']); if ($row['contact_title']) $display_members .= ", ".stripslashes($row['contact_title']); if ($row['phone']) $display_members .= "<br />Tel: ".stripslashes($row['phone']); if ($row['fax']) $display_members .= "<br />Fax: ".stripslashes($row['fax']); if ($row['email']) $display_members .= "<br />".$row['email']; if ($row['website']) $display_members .= "<br /><a href='http://".$row['website']."' target='_blank'>".$row['website']."</a>"; if ($row['year_est']) $display_members .= "<br />Founded in ".$row['year_est']."."; if ($row['org501c3'] == "1") $display_members .= "<br />This organization IS registered with the IRS as a 501(c)3."; if ($row['org501c3'] != "1") $display_members .= "<br />This organization is NOT registered with the IRS as a 501(c)3."; $display_members .= "<br /><br />"; } return "<div class='memberlist'>" . $display_members . "</div>"; } add_shortcode('standardslist', 'listRescueStandards'); How can I achieve the following scenario with an anchor tag? Code: [Select] if(isset($_POST['submit'])) { // execute script } I do need it for a label system to sort content with labels. I have a form on a PHP page which has 11 groups of radio buttons. Is there way to use PHP instead of client-side JavaScript to submit the form values only when one radio button has been selected from each of the 11 groups? Also, is it possible to get the form elements in a PHP page with JavaScript? Why does this JavaScript: Code: [Select] myForm.elements.lengthstop working in a PHP page? I thought it wouldn't affect client-side JS since PHP is server-side code. Thank you! Hi there, I've been tasked with the job of re-doing the company website from scratch and I'm having a bit of trouble with some of the logic involved as I'm not a web designer by trade. Or by any reasonable stretch of the imagination. Anywhoot, what I'm struggling with is this: I have laid out the website so for each of the core business units there is one php page, call it 'page x'. On page x there are two sections; a sidebar and a content section. At the top of page x there is a menu bar with a links to a different category (eg. services, products, about, contacts, etc). What I have at the moment for page x is an INCLUDE statement in each of the subsection which pulls through a html page and plops it down in the right place. What I am struggling with is how to use the links at the top of the page to pull through a different html page depending on what link I click. I was thinking that I could use something a couple of variables, $sidebar and $content, and then some kind of on-click function to pass a string to each of the variables and then use the INCLUDE statement to call the correct pages. What I have tentatively come up with is this : Code: [Select] <a href=#><img src="/MS_Images/service_hlight.jpg" width="100" height="42" onclick=$sidebar = "OutsourceIT_Website/Managed Services/services_side.html" /></a> and then: Code: [Select] <?php include $sidebar; ?> Would this work in principle? How do I go about making sure that the variable in the link is declared properly? Is there a better way to go about doing this that I am missing due to my ignorance? Hope someone can help because Uncle Google is getting fed up with my vague search terms. This little bit of code fires a database insert and gets the keyfield ID number back. Everything works, except the last part: assigning the returned number to the ID attribute of the table cell that was clicked. Looks like $.ajax knows what $(this) is, but forgets before getting to .complete.
How do I get the "this" variable to be recognized inside the .complete function?
$('table td').click(function() { //user clicks a table cell alert($(this).index()); //test case returns '9' $.ajax({ url: "update.php", type: "POST", data: { action: 'clicked', clicked: $(this).index(), //the column that was clicked row: $(this).parent().attr('id').substr(4) //the row that was clicked (tr has an ID attribute like "row22") } }) .complete(function(data) { alert($(this).index()); //test case should return '9', but returns '-1' instead. console.log(data.responseText); //console gets the assigned id from a database insert -- works fine. $(this).attr('id','ros'+data.responseText); //doesn't work. did .complete forget what $(this) is? }); }I thought about making a hidden element, or global variable to assign $(this) to, but that seems like the long way around. Any other ideas? I know with a submit button I can have a new record created when clicking it, but is it possible to do with a text link? Hi, I am new to PHP world!! I am just trying to find a way to disable a button after its been clicked for lets say 5 minutes. I have searched google and haven't found what I am looking for. I just dont want the users to be able to refresh the page and the button becomes enabled again. any code examples with explanation or a simple tutorial will be much appreciated. Thanks Hello - I need a way to execute a stored procedure from a wordpress site with an external database where the stored procedure is housed. I am very limited in php code. All I know is from what little I have used My Custom Functions plugin. Please be very detailed. This stored procedure I run truncates and re-populates a number of tables I use for various reports. I am pulling data from the wp db and creating tables in the external db which make the data easier to read than through the wp meta data. The tables are housed in a separate db so as not to slow down the wp db. The hosting company does not allow 'Events' to run on the mySql db so I am left with figuring out how to create a cron job using a php file which would be the best. Aside from that, I thought a button on an admin page for execution would make it easier if I have to do it be hand. Thanks for your help. |