PHP - Mysql-stored Address As Hyperlink In A Results Page
I'll walk you first through what is working:
<?php echo($user['biz_site'] != '' ? "<h4>Web Site</h4>" . $user['biz_site'] : ""); ?> In a results page, the code renders something that looks like: Quote Web Site http://www.somecoolsite.com What I'd like instead is something like this: Quote Web Site Visit Site ...where the "visit site" links to the site. I'm trying to address a problem of some sites, especially government sites, having 75+ character-long addresses, which messes up the finite space I have allotted for site addresses. Everything I've tried thus far has rendered blank white pages. (the original code posted up top does not produce a hyperlink) Similar TutorialsSo this is the code prior to trying to add a hyperlink echo "<p>Name: " . $item["first_name"] . " " . $item["last_name"] . "<br> Email: " . $item ["email"] . "</p>"; I thought that putting the <a href around the $item['email'] would make the email address a hyperlink but it does not ... it skips the email addresses completely and hyperlinks the names because all fields are $item. echo "<p>Name: " . $item["first_name"] . " " . $item["last_name"] . "<br> Email: " . "<a href=\"mailto: {$item ["email"]} \">" . "</p>"; Thank you for any assistance. Hi again PhpFreaks, yet again I got a problem regarding coding. I have no clue about to go abt this one: I have form which has some: Code: [Select] <table> <tr> <td> <form> Title display info </form> </td> </tr> </table> I need to add an additional link next to title such that when someone clicks on the link the table expands and displays rsult of a query. Code: [Select] <table> <tr> <td> <form> Title LINK if( link is clicked ) { $query=select display query results } else { dont display query results display info } </form> </td> </tr> </table> sorry if i have posted this in the wrong place, wasnt sure wether to post here or mysql. I have made a php calendar, and i am now wanting it to show if there is an event on that day and if so show it in a tool tip. the tool tip is populated by what is in the title="" of the link so i need my events to be shown in there. I have figured out how to show the event but now i am stuck on how to show all events if there is more than one one that day, how i have set it seems to only the second event, probably as the second variable overwrote the first variable. this is the code i have at the minute .............. $result = mysql_query("SELECT * FROM events WHERE day='$day_num' AND month='$fullmonth' AND year='$year'") or die(mysql_error()); $rows= mysql_num_rows($result); if ($rows !="false"){ while($rowout = mysql_fetch_array($result)) { $todayis = $rowout['day'] ."-". $rowout['month'] ."-". $rowout['year'] ."<br>"; $title= $rowout['event'] ."<br><br>";} $firstl = "<a href='' title='". $todayis . $title ."'>"; $lastl = "</a>";} else {$firstl = ""; $lastl = "";} then to display the day and links ................. Code: [Select] <td><? echo $firstl; ?><? print $day_num; ?><? echo $lastl; ?></td> could some one be so kind and help me write it so that it displays all events? here is a link to the calendar, incase its needed. http://www.scripttesting.htmlstig.com/calendar/index.php Many thanks Carl Hi Guys, I have a webpage which has subsequent pages stored in a database e.g. index.php?id=1 The problem being, is that id=1 has it's data pulled from a database. This was fine & dandy until I started to insert PHP...I am trying to get the below to executre <?php $rater_id=1; $rater_item_name='Rate This'; include("rater.php");?> However nothing shows & nothing happens, I know eval can be used but have not been succesfull in implementing this, can someone please help! Hi! I was wondering if there is a way to execute php code which is stored in mysql database using php. At the minute I am using a echo to try and run php code stored in a mysql database but this just displays the code and does not run the php code. Thanks for any help! Hi Please take a look at my code snippet. I don't know how to get the number of rows returned from a MySQL stored procedure so that I can handle it accordingly. Any ideas please? Thanks Okay, so here is the deal. Have a table which stores image as blob files. Now i want to read the image width and height directly from the blob field. Is this possible and if yes, how? Things i tried so far; list($size[0],$size[1],$type, $attr) = getimagesize('image.php?i=26ddd45b02859e836d13d4b9fde34281'); print_r($size); $img = 'image.php?i=26ddd45b02859e836d13d4b9fde34281'; echo imagesy($img); image.php grabs the image from DB and show's it with header("Content-type: image/jpg"); It works for just showing the images with the <img> tag. Any ideas of help would be great! Hello, First post here! I am using a script to store small files into a database. I know it is not highly recommended but this is the only solution I can find in this case. All seems fine when inserting but when retrieving all documents are corrupt. I am working with PHP 5 on Windows server. Part script after upload: (the document is uploaded to the server first and this is working fine) Code: [Select] if (!empty($_FILES)) { $folder = "kenya/docs_temp/";//including last / $tempFile = $_FILES['Filedata']['tmp_name']; $targetPath = dirname(__FILE__); $targetPath = substr($targetPath,0,strrpos($targetPath, "uploadify")). $folder; $targetFile = str_replace('\\','/',$targetPath) . $_FILES['Filedata']['name']; $fileName = $_FILES['Filedata']['name']; $tmpName = $_FILES['Filedata']['tmp_name']; $fileSize = $_FILES['Filedata']['size']; $fileType = $_FILES['Filedata']['type']; $conn=odbc_connect('xxx','xxx','xxxx'); $content = file_get_contents($tmpName,true); $content = addslashes($content); if(!get_magic_quotes_gpc()){ $fileName = mysql_real_escape_string($fileName); } $file_info = pathinfo($_FILES['Filedata']['name']); $addDoc = "INSERT INTO tblfiles (file_name,file_type,file_size,file_content,file_extension) VALUES ('".addslashes($fileName)."','".$fileType."','".$fileSize."','".$content."','".$file_info['extension']."')"; odbc_exec($conn,$addDoc); } The the script to retrieve and output to the browser: Code: [Select] $conn=odbc_connect('xxxx','xxx','xxxx'); //get the document $getF = "SELECT * FROM tblfiles WHERE userId = '".$_GET['userId']."' AND fileId = '".$_GET['fileId']."'"; $rsF = odbc_exec($conn,$getF); $size = floor(odbc_result($rsF,'file_size')); $type = odbc_result($rsF,'file_type'); $name = odbc_result($rsF,'file_name'); $content = odbc_result($rsF,'file_content'); ob_end_clean(); header("Content-length: ".$size.""); header("Content-type: ".$type.""); header('Content-Disposition: attachment; filename="'.$name.'"'); echo $content; And finally here is the structure for the table: Code: [Select] CREATE TABLE `tblfiles` ( `fileId` int(11) NOT NULL auto_increment, `userId` int(11) NOT NULL, `file_name` varchar(100) NOT NULL, `file_type` varchar(100) default NULL, `file_size` int(11) default NULL, `file_content` mediumblob, `file_extension` varchar(50) NOT NULL, PRIMARY KEY (`fileId`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ; many thanks for any assistance. Hi all: I have been going nuts trying to get this to work. I have gone through many attempts based on internet searches and examples that simply do not work. I have files stored in my MySQL db. The files cna be of any type and are being displayed in a listed report. The files are hyperlinked and clickable, but here is the issue: When I click on a file in: http://development.products-and-services.ca/cms/test.php I get: http://development.products-and-services.ca/cms/test2.php?content=DHall_CV_webdev_eng.pdf as a blank page result. The objective is to get a file download alert or to see the file in the browser. Any ideas? I used search function, could not find a subject that addressed my need. I hope I am not repeating a well answered question.
I have two MySql fields I want to hyperlink, but not as text links, but with an image.
Here is truncated code, if more deatail is need, I can post. Both links work fine now, but show the person's email name and google map link text - looks unproffessional and I think the email links may be able to be harvested by spammers.
The E-mail link:
echo "<td><a href=mailto:".$row['email'] . ">" .$row['email'] . "</a></td>";
The Google map link:
echo "<td><a target='_blank' href=".$row['location_map_link'] . ">" .$row['location_map_link'] . "</a></td>";
Can we use images in this code?
I am not a PHP coder!!
Ron Hi i have this while fetch query which brings up a images from the database but know i tried to add a delete link in each image so i add a delete hyperlink inside the query but instead counts the link as if it was a image too. like if i have 5 images it will double to 10 because of the delete hyeprlink why is this happen help please <?php define('ROOT_DIR', './'); define('PROPER', TRUE); /** * include common files */ include_once(ROOT_DIR. 'includes/common.inc.php'); ?> <!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>Untitled Document</title> <link href="css_eurico/lightbox.css" rel="stylesheet" type="text/css" /> <link href="css_eurico/jquery.lightbox-0.5.css" rel="stylesheet" type="text/css" media="screen" /> <script type="text/javascript" src="js_eurico/jquery.js"></script> <script type="text/javascript" src="js_eurico/jquery.lightbox-0.5.min.js"></script> <script type="text/javascript"> $(function() { $('#gallery a').lightBox(); }); </script> </head> <body> <?php $album_id = $_GET['albums']; $photo = mysql_query("SELECT * FROM photos WHERE album_id='$album_id'"); echo '<div id="menu">'; while ($row = mysql_fetch_assoc($photo)) { echo '<div id="gallery">'; echo'<div class="Image">'; echo '<a href=photos/thumbs/'. $row['photo_proper'] . ' "><img class="picture" src="photos/' . $row['photo_proper'] . ' " width="100" height="100 " /></a>'; echo '<h4 class="brand">' . $row['photo_name'] . '</h4>'; echo '</div>'; echo '<a href="index.php">alo</a>'; } ?> </div> </div> </body> </html> Hi folks, I just found this group and joined up! I have encountered a problem that I am not sure how to resolve, and I hope someone can assist. I run this query against my MySQL database: mysql_select_db($database_commdb, $commdb); $query_rsEmailAddress = "SELECT admin_email FROM tbl_admins WHERE admin_id = 1"; $rsEmailAddress = mysql_query($query_rsEmailAddress, $commdb) or die(mysql_error()); $row_rsEmailAddress = mysql_fetch_assoc($rsEmailAddress); $totalRows_rsEmailAddress = mysql_num_rows($rsEmailAddress); ...and want to use the result to populate the "mail to" field for my response form. (I'm doing this to avoid having my email address posted in a page to be skimmed.) I presently use this: $to = rsEmailAddress['admin_email']; I do some empty fields checking before submitting the form. However, when I click on submit, my form, tells me I have empty fields and will not process when there are NO empty fields. HOWEVER, if I hard-code my email address in the variable "$to" all is well, the form processes correctly, I get the email, etc... So I suspect the problem lies somewhere in the way I have constructed the $to variable. I have scratched my head till I am going bald(er) and my scalp is bleeding!!! HELP!! Please!! This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=359217.0 Hi All, I need to subtract dates and display the number of days left. I have a 'Start' date and an 'End' date in DATETIME format in the DB. Not quite sure where to start. A simply start - end doesn't work . Start = 2011-11-01-00:00:00 End = 2011-11-30-23:59:59 Since it is now 2011-11-27, my output should equal 3. Any help is appreciated. any one? I have a form with PHP validation and also a mysqli query checking for duplicates in the database for mailing address and email address in mysql.
It works fine but the customers are adding spaces in the mailing address for example 111 mailing address A V E, 1 1 1 ma iling address A V E etc. and my sql query doesn't see that as an address that's a duplicate.
Their alslo adding email address like my@emailaddress.com and m.y@emailaddress.com, m.y.2@emailaddress.com etc to bypass that comparision also.
Is there anyway to stop this from happening?
wrote a stored procedure this morning and i don’t know how to get the values out of it through a class function in php or phpmyadmin. here is what i wrote : public function totalProcedures($friend_name,$session_id) { /* *query to fetch stored procedure */ try { //executing the stored procedure $sql_sp="CALL timeline (:friend, :session,@updates, @group_posts)"; $stmt_sp= $this->_db->prepare($sql_sp); $stmt_sp->bindValue(":friend",$friend_name); $stmt_sp->bindValue(":session",$session_id); $stmt_sp->execute(); $rows=$stmt_sp->fetch(PDO::FETCH_ASSOC); $stmt_sp->closeCursor(); // closing the stored procedure //trying to get values from OUT parameters. $stmt_sp_2=$this->_db->prepare("select @updates,@group_posts"); $stmt_sp_2->execute(); return $stmt_sp_2->fetch(PDO::FETCH_ASSOC); } catch (PDOException $ei) { echo $ei->getMessage(); } } can someone helpme how to get results. here is the storedprocedu DELIMITER $$ CREATE DEFINER=`root`@`localhost` PROCEDURE `timeline`(IN `friend` VARCHAR(255), IN `session_id` VARCHAR(255), OUT `updates` VARCHAR(62555), OUT `group_posts` VARCHAR(62555)) BEGIN select * FROM updates where author in (friend,session_id) order by time desc limit 5; select * FROM group_posts where author_gp in (friend,session_id) order by pdate desc limit 5; END$$ DELIMITER ; i get the result in php myadmin as follows:
how do i do this inside a php class function. CALL timeline('shan2batman','aboutthecreator', @updates, @group_posts);
How can I limit the amount of time my while loop to only show the first 4 rows of my SQL table?
I am using this code to loop my whole table:
while($row = $results->fetch(PDO::FETCH_ASSOC)) { echo ' <li>Mileage: '.number_format($row["Mileage"]).'</li> <li>Engine size: '.$row["EngineSize"].'cc</li> ';} ?>I only want to loop through the first 4 rows of my SQL table, I then want to duplicate the same code but start at the 5th row until the 8th row of the table, how can I do this? Thanks, Nick What's the best way to format results from a MySQL table? I've found very vague examples of PHP code utilizing html tables. Below is my current PHP. Thanks! <?php $con = mysql_connect("localhost","xxxxx","xxxxx") or die('Could not connect: ' . mysql_error()); mysql_select_db("addresses", $con); $result = mysql_query("SELECT * FROM addresses"); while($row = mysql_fetch_array($result)) { echo $row['first_name'] . " " . $row['last_name'] . " " . $row['extra_info'] . " " . $row['address'] . " " . $row['city'] . " " . $row['state'] . " " . $row['zip']; echo "<br />"; } mysql_close($con); ?> |