PHP - Target Attribute In Php Hyperlink
I have researched the subject and found a few 'solutions' for my problem but cannot get it to work (I looked at ones in this forum). <?php //loop to collect and output db data as hyperlink with target="_blank" while($row = mysqli_fetch_assoc($result)) { //output data from each row echo "<a href='".$row[link]."'>♦ ".$row[title]."</a><br>"; } ?>
Similar TutorialsHow can I make this link have a target blank suited for a Strict doctype. if (strpos($row['personalweb'], 'http://') === false && strpos($row['personalweb'], 'https://') === false) { $row['personalweb'] = "http://${row['personalweb']}"; } This seems like it should be simple but it's driving me crazy... I have a site that I use a login in conjunction with frames. After some time of inactivity, the session expires and when a link is clicked in one of the frames, that frame redirects to the login page. I would like for it to exit the frames and go to the login page. I'm using the header tag to redirect... like this header("Location: index.php"); How can I incorporate "Target='_top'" or something similar to achieve the desired effect? this one is form2 .php and there is action link button where im want the target to open new browser for example now m using google chrome so when im click the action link it will open another browser which is bit actually the photo is in one im dont know how to combine that why im splitted but how to target like that Hello I am trying to show/geo target content for certian countries that my visitors to my site are from. I have doing a little research on google and have found a few script but for some reason they do not work. I know about the geoip database from maxmind but I am looking for a remote solution as the geoip database is said to be a heavy strain on servers if you get a lot of visitors. I am hosted on a shared server so I do not want to get my account suspended for over working the server. Also I have a few sites that will use this idea. This is a script I found whilst googling and all it does is give me an error. Code: [Select] <?php $ip = $_SERVER [ 'REMOTE_ADDR' ]; $country = file_get_contents ( 'http://api.hostip.info/country.php?ip=' . $ip ); if ( $country == "US" ) { echo "<American-English Ringtone Ad Tag>" ; } elseif ( $country == "AU" OR $country == "UK" OR $country == "IE" ) { echo "<British-English Ringtone Ad Tag>" ; } else { echo "<YPN Ad Tag>" ; } ?> This is the error it gives me:- Quote Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/username/public_html/webaddress.co.uk/test/test.php on line 7 What I am trying to do is to geo target Javascript ads for different countries. When I add the javascript ad it gives me that error. If I just put in normal text then it works ok. Thank you all for your help in advance. Hi.. I know target blank has become a security risk, but I am curious to know if this link is now being disallowed or if I have coded it wrong. The link works, but it will not go to a new page. Thanks for any help. $id = "<a href=pgpage.php?id=" . $idr . "target = '_blank'>" . $partno . "</a>"; This link is driving me crazy <a id ="savepdf" href="invoice.php?invoice_id=<?=$invoiceID?>"value="Save This Invoice"><button class="block" id ="printbtn" onclick="myFunction()";>Save Invoice</button></a>
when a user selects this link it works ok saves a pdf file to a folder on server. i want to relocate after link submitted. If i use this link it does redirect but does not save the pdf file to folder on server <a id ="savepdf" href="invoice.php?invoice_id=<?=$invoiceID?>"value="Save This Invoice" onclick="window.location.href='mypage.php'; ;return false;"><button class="block" id ="printbtn" onclick="myFunction()";>Save Invoice</button></a> Dear all PHP experts need your help please as I'm very new the PHP. I found this php form script on the net which works perfectly but only uploads one file. I need to upload a second file and send it to a different folders and a different field on the database. I have viewed a number of site and changed the code a number of time without success I have put the code back to original script, can some one please show me what I need to do. Thanks <form action="upload.php" method="post" enctype="multipart/form-data"> <label>First Name</label><input type="text" name="fname" /><br /> <label>Last Name</label><input type="text" name="lname" /><br /> <label>Upload Image</label> <input type="file" name="image" /><br> <label>Spec</label> <input type="file" name="spec" /><br /> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> <input type="submit" id="submit" value="Upload" /> </form> Script function is_valid_type($file) { $valid_types = array("image/jpg", "image/jpeg", "image/bmp", "image/gif"); if (in_array($file['type'], $valid_types)) return 1; return 0; } function showContents($array) { echo "<pre>"; print_r($array); echo "</pre>"; } $TARGET_PATH = "images/"; $fname = $_POST['fname']; $lname = $_POST['lname']; $image = $_FILES['image']; $fname = mysql_real_escape_string($fname); $lname = mysql_real_escape_string($lname); $image['name'] = mysql_real_escape_string($image['name']); $TARGET_PATH .= $image['name']; if ( $fname == "" || $lname == "" || $image['name'] == "" ) { $_SESSION['error'] = "All fields are required"; header("Location: index.php"); exit; } if (!is_valid_type($image)) { $_SESSION['error'] = "You must upload a jpeg, gif, or bmp"; header("Location: index.php"); exit; } if (file_exists($TARGET_PATH)) { $_SESSION['error'] = "A file with that name already exists"; header("Location: index.php"); exit; } if (move_uploaded_file($image['tmp_name'], $TARGET_PATH)) { $sql = "insert into people (fname, lname, filename,spec) values ('$fname', '$lname', '" . $image['name'] ."')"; $result = mysql_query($sql) or die ("Could not insert data into DB: " . mysql_error()); header("Location: images.php"); exit; } else { $_SESSION['error'] = "Could not upload file. Check read/write persmissions on the directory"; header("Location: index.php"); exit; } I have an edit page but whenever I click edit the pathname of the original file is not in the file box so everytime I hit the save button , it will be considered as no file so my previous image or file will be overwritten by "nothing". I want to get the url in the [@attributes] Atm i get the title like this Code: [Select] foreach ($xmlTree->channel->item as $item) { echo '<p>'.$item->title.'</p>'; } i tried this Code: [Select] $imageUrl = $item->enclosure->@attributes->url; print_r2($imageUrl); but then i get this error: Quote Parse error: syntax error, unexpected '@', expecting T_STRING or T_VARIABLE or '{' or '$' in / this is the XML: Quote => SimpleXMLElement Object ( [title] => #3315: Woord van het jaar: weigerambtenaar, Arabische lente tweede, plaszak derde [link] => http://www.nrc.nl/nieuws/2011/11/26/woord-van-het-jaar-weigerambtenaar/?utm_campaign=rss&utm_source=syndication [pubDate] => Sat, 26 Nov 2011 17:00:55 +0100 [guid] => nieuws_153690 [description] => SimpleXMLElement Object ( ) [enclosure] => SimpleXMLElement Object ( [@attributes] => Array ( [url] => http://www.nrc.nl/wp-content/uploads/2011/11/vmBruidstaart5501_63103-586x4801-300x245.jpg [length] => [type] => image/jpeg ) ) ) Need Suggestion for my codes, I want msg1.php to be open in the frame bottomframe. if($username=="" || $password=="") { echo "<form method=\"post\" action=\"msg1.php\" target=\"bottomframe\" >"; } Hello, I need help with php, I don't understand what that could be , otherwise I run the page via a wampserver, I would be grateful for any kind of help. Hi, Is it possible to send an auto email to a person as per the target date in a datagrid column of Flash CS4 (AS 3.0)? I was told that PHP will help in this regard. I have the following example file attached herewith. It should check the target date column and if the target date is equal to current date then it should send an auto e-mail to the respective person using the E-Mail ID from the Flash datagrid control. For example (as per attached list): An email to be sent to Mr. Rangarajan on 15-APR-12 with subject "Submission of BCM Procedure draft" using his email id from the "E-Mail" column of the grid i.e. rrajan@demo.com Please let me know whether it is possible in PHP? Thanks. <form action="jvs.php" method="post"> <input type="checkbox" name="box" value="haa"> <input type="submit" value="submit"> </form> <?php echo $_POST['name']; ?> hi all How can I get the value of name which is box through post or get from the code I want to remove the current attribute of the tag and add the new one. I wrote the php program but it gives me no output. Can someone help me please??? Here is my code!!! <?php $xml = new DOMDocument(); $xml->load('test.xml'); $node = $xml->getElementsByTagName('*'); $nodename = ""; $node_name = ""; $att = ""; $attr_name = ""; $attr_value = ""; foreach($node as $value) { echo "Node Name is :".$value->nodeName; $nodename = $value->nodeName; $node_name = $xml->getElementsByTagName('$nodename')->item(0); echo $nodename; foreach($nod_name as $value1) { $att = $node_name->getAttributeNode('$value1'); echo "Node Name is :".$att->name; echo "<BR>Attribute Value is :".$att->value; $attr_name = $att->name; $attr_value = '"' . $att->value . '"'; $nodename->removeAttributeNode('$attr_name'); $nodename->setAttributeNode(new DOMAttr('$attr_name', '$attr_value')); } $xml->save('temp1.xml'); } ?> I have a parser.php file that presents me with a list of items inside an XML file differences.xml: <element> <item code="lM" name="castle" type="building"> <cost>5000</cost> </item> .....more items..... After selecting wanted items, the form submits to parsed.php. Now I want parsed.php to go back into the same XML file and insert only those selected items into a new array. parser.php code: <?php if (empty($option)){ $xml = simplexml_load_file('differences.xml'); $object = $xml->xpath('//item'); $count = count($object); $i = 0; echo "<form method='post' action='parsed.php'>"; while($i < $count){ $xmlname = $object[$i]['name']; echo "<input type='checkbox' name='option[".$i."]' value='$xmlname'>".$xmlname; echo "<br>"; $i++; } echo "<br><input type='submit' name='formSubmit' value='Proceed'><br>"; echo "</form>"; } ?> parsed.php code: <?php $option = $_POST['option']; if (isset($_POST['formSubmit'])) { if (!empty($option)){ $xml = simplexml_load_file('differences.xml'); $i = 0; $count = count($option); while($i < $count) { $object = $xml->xpath('//item[@name="$option[$i]"]'); echo $object[$i]['name']; echo "<br>"; $i++; } }else{ echo "No items selected, Please select:"; } } ?> The problem I am having is that echo $object[$i]['name']; is not returning any values (it is empty, I checked). The thing is though that $option[$i] does contain the selected value. I have narrowed my problem down to this part of my code: $object = $xml->xpath('//item[@name="$option[$i]"]'); echo $object[$i]['name']; Can someone help me narrow down my problem? Hey guys Just a quick question: How to embed hyperlink into a database cell? Basically I echo out a table on the user interface of my site and there's an URL in one of the cells I want the user to access it by clicking on it, without copying and pasting the URL into the URL bar of the browser I tried updating the cell in phpmyadmin using <a href = http://www.example.com>http://www.example.com</a> but didn't work out, the resulting cell only had the text format Any help would be appreciated Thanks. Hi All, Not sure if this is a silly question so here we go. I have some divs that have data attributes (data-value). When i submit and post the form, can i use these values as part of the submission and put their data-value into the db? Thanks as always in advance. I have searched this forum and haven't found a solution to my question. please don't flame... I am trying to send a table field from one page to another. the field i'm sending is id. I have managed to populate the field updateplayer.php?id=***** now i have a syntax error trying to get the field to show up on the update player form. Parse error: syntax error, unexpected T_VARIABLE in /home/netman13/public_html/bccsl.org/managers/updateplayer.php on line 7 The id field is supposed to get the id variable from the previous page ?id=***** Here is the update player code: Code: [Select] <?php include 'dbc.php'; $qP = "SELECT * FROM players WHERE id = '$_GET['$id']' "; $rsP = mysql_query($qP); $row = mysql_fetch_array($rsP); extract($row); $id = trim($id); $first = trim($first); $last = trim($last); $address = trim($address); $city = trim($city); $postal = trim($postal); $phone = trim($phone); $feet = trim($feet); $inches = trim($inches); $weight = trim($weight); $birth = trim($birth); $status = trim($status); $number = trim($number); mysql_close(); ?> <!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=utf-8" /> <title>Update Player</title> <link href="styles.css" rel="stylesheet" type="text/css"> <script language="JavaScript" type="text/javascript" src="js/jquery-1.3.2.min.js"></script> <script language="JavaScript" type="text/javascript" src="js/jquery.validate.js"></script> <script> $(document).ready(function(){ $.validator.addMethod("username", function(value, element) { return this.optional(element) || /^[a-z0-9\_]+$/i.test(value); }, "Username must contain only letters, numbers, or underscore."); $("#regForm").validate(); }); </script> </head> <body> <script language="JavaScript"> <!-- /*********************************************** * Required field(s) validation v1.10- By NavSurf * Visit Nav Surf at http://navsurf.com * Visit http://www.dynamicdrive.com/ for full source code ***********************************************/ function formCheck(formobj){ // Enter name of mandatory fields var fieldRequired = Array("first", "last", "address", "city", "postal", "phone", "hft", "hinch", "weight", "birthdate", "status"); // Enter field description to appear in the dialog box var fieldDescription = Array("First Name", "Last Name", "Address", "City", "Postal Code", "Phone Number", "Feet", "Inches", "Weight", "Birthdate YYYY/MM/DD", "Player Status"); // dialog message var alertMsg = "Please complete the following fields:\n"; var l_Msg = alertMsg.length; for (var i = 0; i < fieldRequired.length; i++){ var obj = formobj.elements[fieldRequired[i]]; if (obj){ switch(obj.type){ case "select-one": if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; case "select-multiple": if (obj.selectedIndex == -1){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; case "text": case "textarea": if (obj.value == "" || obj.value == null){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; default: } if (obj.type == undefined){ var blnchecked = false; for (var j = 0; j < obj.length; j++){ if (obj[j].checked){ blnchecked = true; } } if (!blnchecked){ alertMsg += " - " + fieldDescription[i] + "\n"; } } } } if (alertMsg.length == l_Msg){ return true; }else{ alert(alertMsg); return false; } } // --> </script> <table width="100%" border="0" cellpadding="5" cellspacing="0"class="main" > <tr> <td colspan="1"><p></p></td> </tr> <tr> <td width="17%"><? //Call Menu include 'menu.php'; ?></td> <td width="3%"> </td> <td width="80%"><p align="center">Update Player Information</p> <p align="center"><? if (isset($_GET['msg'])) { echo "<div class=\"msg\">$_GET[msg]</div>"; } ?></p> <p align="center"> </p> <form action="playerupdate.php" method="post" enctype="multipart/form-data" name="form" id="form" onsubmit="return formCheck(this);"> <table width="653" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="148" height="29">First Name</td> <td width="153"><label> <input name="first" type="text" disabled="disabled" class="required" id="first" value="<?=$first ?>" /> </label></td> <td width="91" height="30">Last Name</td> <td width="261"><label> <input name="last" type="text" class="required" id="last" value="<?=$last ?>" readonly="readonly" /> </label></td> </tr> <tr> <td height="30">Address</td> <td><input name="address" type="text" class="required" id="address" value="<?=$address ?>" /></td> <td>City</td> <td><label> <input name="city" type="text" class="required" id="city" value="<?=$city ?>" /> </label></td> </tr> <tr> <td height="28">Postal Code</td> <td><label> <input name="postal" type="text" class="required" id="postal" value="<?=$postal ?>" size="12" /> </label></td> <td>Phone Number</td> <td><label> <input name="phone" type="text" class="required" id="phone" value="<?=$phone ?>" size="13" /> </label></td> </tr> <tr> <td height="29">Height <strong>(ft / in)</strong></td> <td><label> <input name="feet" type="text" class="required" id="feet" value="<?=$feet ?>" size="3" /> / <input name="inches" type="text" class="required" id="inches" value="<?=$inches ?>" size="3" /> </label></td> <td>Weight (lbs)</td> <td><input name="weight" type="text" class="required" id="weight" value="<?=$weight ?>" size="5" /></td> </tr> <tr> <td height="35">Birthdate <strong>(yyyy/mm/dd)</strong></td> <td><label> <input name="birth" type="text" class="required" id="birth" value="<?=$birth ?>" size="13" readonly="readonly" /> </label></td> <td><label>Player Type:</label></td> <td><p> <label> <input name="status" type="radio" id="type_0" value="1" checked="checked" /> Church</label> <br /> <label> <input type="radio" name="status" value="2" id="type_1" /> Import</label> <br /> <label> <input type="radio" name="status" value="3" id="type_2" /> Witness</label> <br /> </p> <label></label></td> </tr> <tr> <td height="35">Player ID:</td> <td><input name="id" type="text" id="id" value="<?=$id ?>" readonly="readonly" /></td> <td>Player Number:</td> <td><input name="number" type="text" class="required" id="number" value="<?=$number ?>" size="5" /></td> </tr> <tr> <td height="29"> </td> <td><label></label></td> <td><p> <input name="teamid" type="hidden" id="teamid" value="<? echo $_SESSION['teamid'];?>" /> <input name="division" type="hidden" id="division" value="<? echo $_SESSION['divisionid'];?>" /> <input type="hidden" name="currentdate" size=11 > </p> <p> <input name="teamname" type="hidden" id="teamname" value="<? echo $_SESSION['team_name'];?>" /> </p> <p> <script> /*Current date in form credit: JavaScript Kit (www.javascriptkit.com) Over 200+ free scripts here! */ var mydate=new Date() var theyear=mydate.getYear() if (theyear < 1000) theyear+=1900 var theday=mydate.getDay() var themonth=mydate.getMonth()+1 if (themonth<10) themonth="0"+themonth var theday=mydate.getDate() if (theday<10) theday="0"+theday //////EDIT below three variable to customize the format of the date///// var displayfirst=theyear var displaysecond=themonth var displaythird=theday //////////////////////////////////// document.form.currentdate.value=displayfirst+"/"+displaysecond+"/"+displaythird </script> <input name="approved" type="hidden" id="approved" value="0" /> </p></td> <td> </td> </tr> </table> <p align="center"> <label> <input type="submit" name="submit2" id="submit2" value="Submit" /> </label> <label> <input type="reset" name="reset2" id="reset2" value="Clear" /> </label> </p> </form> <p align="center"> </p> <p align="center"> <label></label> </p></td> </tr> <tr> <td colspan="3"> </td> </tr> </table> <p> </p> </body> </html> Thanks for your help. This forum has been an awesome resource for me. Hello im wondering how i can make a hyperlinks adress be a set after a variable. this is my php: $result1 = mysql_query("SELECT id, namn, url FROM stuff ORDER BY id desc limit 1;"); $result2 = mysql_query("SELECT id, namn, url FROM stuff ORDER BY id desc limit 1,1;"); <html> <a href="???"> <p class="note-general"> The first link </p> <a href="???"> <p class="note-general"> The the second link </p> </html> The important thing is that the url from $result1 will link under "the first link" and url from $result2 link under "the second link". |