PHP - Opening A Particular Page Of A Pdf By Clicking A Hyper Link
Hi..
I have an issue on my project.I want to open a particular page of a PDF file by clicking a hyper link.How should I do it?any idea ? I used the following code <?php header("Content-Type: application/pdf"); $pdfFile="readme.pdf#page=10"; ?> <html> <head> <title>Untitled Document</title> </head> <body> <a href="http://<?php echo $pdfFile; ?>">Click Here</a> </body> </html> But it showing an alert like following File does not begin with '%PDF-' After clicking alert showing a black screen.. can u please send me the entire code? Thanks... Similar TutorialsHi, I have a search results from a query like this: Accomodation & Housing Aqua & Hatcheries Automotive Beauty,Body & Sourl Billing Construction Education Electrical & Electronics Entertainment Financial Services Food & Dining Freelancers Health Services Home & Garden Industries Miscellaneous I wanted to hyper link these lines as an input to further query: For example: A link should establish to line item Industries, when i click on this, a further query to run with the results from another table with key word "Industries". Can somebody please help me on this issue. I am using dream weaver 5.5 for this project, if any help in this issue is greatly appreciated. Thanks, I have a PHP application where I am trying to execute a PHP routine when the user clicks on a link to go to another page. The routine needs to execute before I use a header location command to send the user to the next location. I can't do this all with JavaScript, but it could be part of the solution if necessary. I'd prefer to just use PHP if I could, but I'm not sure that this is possible. Can anyone share with me a brief example of how I could do this? Thanks! Hi
I'm trying to change an image when a certain link is clicked. The image is a logo of a company and the links that will be clicked is english, arabic, and Chinese.
So if someone clicks on Chinese then the logo changes to the Chinese version of the normal logo.
Here is my html
<?php $langArabic=''; $langChinese=''; $langSpanish=''; $langEng=''; $linkArabic=getSEOLink($page_id); $linkChinese=getSEOLink($page_id); $linkSpanish=getSEOLink($page_id); $linkEng=getSEOLink($page_id); $queryLink = mysql_query("SELECT * FROM $_SEO_TABLE WHERE `id_page`='".$page_id."'"); if(mysql_num_rows($queryLink) > 0){ $resultLink = mysql_fetch_object($queryLink); if($resultLink->url != ''){ $linkEng = $_HTTP_ADDRESS."".$resultLink->url; if($page_id == 1 || $page_id == '1'){ $linkEng = $_HTTP_ADDRESS; } } if($resultLink->url_arabic != ''){ $linkArabic = $_HTTP_ADDRESS."".$resultLink->url_arabic; } if($resultLink->url_chinese != ''){ $linkChinese = $_HTTP_ADDRESS."".$resultLink->url_chinese; } if($resultLink->url_spanish != ''){ $linkSpanish = $_HTTP_ADDRESS."".$resultLink->url_spanish; } } switch (urlExtension()) { case 'html': $langClass = ''; $langEng='langActive'; $langTag='en'; break; case 'ar': if($page->title_arabic == ''){ $langClass = '_arabic'; }else{ $langClass = '_arabic'; } $langArabic='langActive'; $langTag='ar'; break; case 'es': $langClass = ''; $langSpanish='langActive'; $langTag='es'; break; case 'cn': $langClass = ''; $langChinese='langActive'; $langTag='cn'; break; default: $langClass = ''; $langEng='langActive'; $langTag='en'; } ?> <a class="main-logo<?php echo $langClass;?>" href="javascript:void(0);"><img src="<?php echo $_HTTP_ADDRESS;?>images/logo-letters.png" /></a> <div class="language-selection-wrapper<?php echo $langClass;?> overlay-bg<?php echo $langClass;?> border-bottom-white<?php echo $langClass;?> padding-level-one<?php echo $langClass;?>"> <div class="language-inner-wrapper<?php echo $langClass;?>"> <a class="<?php echo $langEng;?>" href="<?php echo $linkEng;?>">English</a><span>|</span> <a class="<?php echo $langArabic;?>" href="<?php echo $linkArabic;?>">العربيّة</a><span>|</span> <a class="<?php echo $langSpanish;?>" href="<?php echo $linkSpanish;?>">Español</a><span>|</span> <a class="<?php echo $langChinese;?>" href="<?php echo $linkChinese;?>">中文</a> <div class="clearboth"></div> </div> So I am trying to execute an sql query by clicking a button or a link. Ultimately I want users to be able to click the "Fav" button and it then fades into "Added to favorites!" (I am building a favorite system which first collects data on page load like userid and itemid and then it needs to send it to the DB after a button is clicked) The fade and stuff is not the most important part now (although a tip on doing that would be awesome) but the most important part is how to get this functional: PHP Code: <?php // Start Favorite System! $user =& JFactory::getUser(); $userid = $user->id; if ($userid == 62) { echo "userID: ".$userid."<p />"; if ($user->guest) {echo "You are a guest<p />";} $itemid = $this->item->id; echo "itemID: ".$itemid."<p />"; $catid= $this->item->category->id; echo "catID: ".$catid."<p />"; $query = "INSERT INTO jos_k2_fav_xref (userID, itemID, catID) VALUES ('$userid', '$itemid', '$catid')"; // Need a way to make this into a button $run = mysql_query($query) or die(mysql_error()); } else {} ?> Currently all the values get stored in the DB as the page is loaded. I however want to be able to click on something to execute that query how do i do that? I read a bunch of stuff on javascript and ajax but it got me nowhere... Help is greatly appreciated! Goal: To have a gallery that downloads images from the folder I previously uploaded to in a previous script. Bug: When I load the page the thumbnail comes up as broken and when I click on the thumbnail to get the bigger picture it comes up with the following error message: "Firefox doesn't know how to open this address, because the protocol (c) isn't associated with any program." <?php include 'db.inc.php'; //connect to MySQL $db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD) or die ('Unable to connect. Check your connection parameters.'); mysql_select_db(MYSQL_DB, $db) or die(mysql_error($db)); //change this path to match your images directory $dir ='C:/x/xampp/htdocs/images'; //change this path to match your thumbnail directory $thumbdir = $dir . '/thumbs'; ?> <html> <head> <title>Welcome to our Photo Gallery</title> <style type="text/css"> th { background-color: #999;} .odd_row { background-color: #EEE; } .even_row { background-color: #FFF; } </style> </head> <body> <p>Click on any image to see it full sized.</p> <table style="width:100%;"> <tr> <th>Image</th> <th>Caption</th> <th>Uploaded By</th> <th>Date Uploaded</th> </tr> <?php //get the thumbs $result = mysql_query('SELECT * FROM images') or die(mysql_error()); $odd = true; while ($rows = mysql_fetch_array($result)) { echo ($odd == true) ? '<tr class="odd_row">' : '<tr class="even_row">'; $odd = !$odd; extract($rows); echo '<td><a href="' . $dir . '/' . $image_id . '.jpg">'; echo '<img src="' . $thumbdir . '/' . $image_id . '.jpg">'; echo '</a></td>'; echo '<td>' . $image_caption . '</td>'; echo '<td>' . $image_username . '</td>'; echo '<td>' . $image_date . '</td>'; echo '</tr>'; } ?> </table> </body> </html> Any help appreciated. Hi there, I am new to PHP and trying to put my learning together as I progress. Here's the problem: I would like to open HTML file after a certain condition is met. I tried to fopen() but it gave an empty page. Here's the code: Code: [Select] <?php $shape = $_POST['shape']; if($shape=='Triangle') { fopen('ogc_show_triangle.php', 'r'); } else { echo "Select a shape."; } ?> Thanks in advance! ^_^ Hi, I am creating an access control page where my end user swipes his card and the page auto submits. At this stage I want to click his/her picture as well. The challenge is I am unable to find a script where a webcam clicks on page refresh or when it auto submits.. All the scripts i have seen only work on a click which is not possible here as the only user input is a swipe which has an autosubmit. This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=357107.0 Hi guys, I know that you can open web page with $handle = fopen("http://www.example.com/", "r"); but i am wondering is there a way to pass POST vars when doing so, or there is another method that can that like you do it with ajax. I have mvc application that i want to test. I am using CodeIgniter framework so i want to call my controllers with POST values. Every controller method returns data holder object that holds the data of operation whether is successful or not. Also every method inside controller can be called with parameter input or with post input. If you omit the parameters when calling controller method than he will try to load that parameters from post and that is why i want to pass POST vars with php when calling controller for example i want to call: fopen("http://localhost/MyAppFolder/index.php/controller/method"); but i want to pass it some POST vars if that is possible Thanks. Hello, everyone. I have code that effectively calls a PHP page with AJAX (no JQuery). The PHP responds fine with an echo. Here is the javaScript that calls the PHP so refreshing the page doesn't need to be done.
function deleteCategory() { var e= document.getElementById("dropDown1"); var var1 = e.options[e.selectedIndex].text; var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = alerta() { if (this.readyState == 4 && this.status == 200) { document.getElementById("insert").innerHTML = xmlhttp.responseText; } }; xmlhttp.open("GET", "deleteRow.php?q=" + var1 , true); xmlhttp.send(); } How do I call a PHP function on the same page while preserving the above AJAX.
Sincerely, Joshua This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=326913.0 Hello.
I have a bit of a problem. When I fetch the link field from the database.i don't see an actual link on the page.
One more thing, what type of field should I use to store the link in the database? Probably there is where I went wrong.
All help is
Hello. I hope one of the PHP/HTML gurus here can help me. I have a web page that has been altered a bit to add some Google Analytics stuff and I've moved it to a 2nd directory. The original one works fine, the 2nd one won't post the form when I click the submit button. 1st URL https://www.theneutralizer.info/neutralizer 2nd URL: https://www.theneutralizer.info/neutralizer2 I have changed the action property to the correct script, and it does exist. But the problem is when clicking the button nothing happens. Anyone have any ideas? I can send the PHP code if needed, but since it's HTML output, it should work the way it is displayed in the browser. David Please, take a look to the following code.After clicking Next it goes to overview.php.Why when I click back on my browser to return to this page again, it is not returning back? When I click back I receive "Confirm Form Resubmission" message. After refreshing page it loads page. I guess problem is in "session_start();" part. Something to do with cookies. Please, help me it is very urgent for me. <?php session_start(); echo "<html> <head> <title>Hello World</title> <meta http-equiv='Content-Type' content='text/html; charset=Windows-1252'/> </head>"; require_once ('functions.inc'); if(!isset($_POST['userid'])) { echo "<script type='text/javascript'>"; echo "window.location = 'index.php'"; echo "</script>"; exit; }else{ session_register("userid", "userpassword"); $username = auth_user($_POST['userid'], $_POST['userpassword']); if(!$username) { $PHP_SELF = $_SERVER['PHP_SELF']; session_unregister("userid"); session_unregister("userpassword"); echo "Authentication failed " . "Please, write correct username or password. " . "try again "; echo "<A HREF=\"index.php\">Login</A><BR>"; exit; } } function auth_user($userid, $userpassword){ global $default_dbname, $user_tablename; $user_tablename = 'user'; $link_id = db_connect($default_dbname); mysql_select_db("d12826", $link_id); $query = "SELECT username FROM $user_tablename WHERE username = '$userid' AND password = '$userpassword'"; $result = mysql_query($query) or die(mysql_error()); if(!mysql_num_rows($result)){ return 0; }else{ $query_data = mysql_fetch_row($result); return $query_data[0]; } } echo "hello"; echo "<form method='POST' name='myform' action='overview.php'>"; echo "<input type='submit' value='Next'>"; echo "</form>"; ?> Hi, Is it possible to build a PHP Template page that selects and publishes a row of data from a MySQL Database when a linked is clicked? I would design: Template.php Text links (perhaps on homepage of navigation bar): ProductA, ProductB and ProductC If you click link ProductA Template.php would display data for ProductA and likewise for ProductB and ProductC. I would also like search engines for find ProductA, ProductB and ProductC PHP pages. (Not just my single Template.php) Any ideas as to how this could be done without designing individual PHP pages for each product? Kind regards, Matthew. ok so now all my logo link goes to the same page..i dont know how to fix it.i want all of them connect to a link(each of the company has their own company_link id) which i named company_link which is already in the database..so i need to call it.there are about 20 total logos.. except for the $company id=33..just remain that one.. Code: [Select] <? if(isset($_GET[ttid])) { $ttid = $_GET[ttid]; } $connection=mysql_connect("$server", "$username", "$password") or die("Could not establish connection"); mysql_select_db($database_name, $connection) or die ("Could not select database"); $query = "select master_event.* , (DATE_FORMAT(event_datefrom, '%d %M %Y')) as datefrom, (DATE_FORMAT(event_dateto, '%d %M %Y')) as dateto, ucase(event_name) as eventname from master_event where master_event.event_id = '$ttid '"; $result=mysql_query($query); while($row = mysql_fetch_array($result)){ $eventname = $row['eventname']; $eventdesc = $row['event_desc']; $companydescription = $row['company_description']; $eventvenue = $row['event_venue']; $eventfee = $row['event_fee']; $datefrom = $row['datefrom']; $dateto = $row['dateto']; echo "<font color='#000000' face='arial' ><b> $eventname </b> </font> <br>"; echo "<font color='#000000' face='arial' ><i>Date</i> : $datefrom - $dateto <br>"; echo "<i>Venue</i> : $eventvenue <br>"; $querypstype = "SELECT DISTINCT master_pstype.pstype_id, pstype_desc FROM master_pstype INNER JOIN master_psevent ON master_psevent.pstype_id= master_pstype.pstype_id where master_psevent.event_id = '$ttid' ORDER BY pstype_id"; $resultpstype=mysql_query($querypstype); while($rowpstype = mysql_fetch_array($resultpstype)){ $pstypeid = $rowpstype['pstype_id']; $pstypedesc = $rowpstype['pstype_desc']; echo "<br><font color='#8B3A3A' size='1' face='georgia' ><b><i>$pstypedesc</i></b></font> <br>"; $queryps = "SELECT master_psevent.*, pstype_desc, company_name, company_link, company_description, logo_filename FROM master_psevent LEFT JOIN master_pstype ON master_psevent.pstype_id = master_pstype.pstype_id LEFT JOIN master_ps ON master_ps.ps_id = master_psevent.ps_id WHERE master_psevent.event_id = '$ttid' and master_pstype.pstype_id= '$pstypeid' ORDER BY pstype_desc,company_name "; $resultps=mysql_query($queryps); while($rowps = mysql_fetch_array($resultps)){ $companyname = $rowps['company_name']; $companyid = $rowps['ps_id']; $companylinkori = $rowps['company_link']; $companydescription = $rowps['company_description']; if ($companyid==33){ $companylink = "http://(confidential)/index.php?view=describe"; } else { if ($companylinkori <> "") { //$companylink = "http://".$rowps['company_link']; $companylink = "http://(confidential)/index.php?view=".$companyid; } else { $companylink = ""; } } $logopath = $rowps['logo_filename']; if ($companylink <> ""){ echo "<font color='#4A708B' face='arial' ><a href=$companylink style=\"color:white;text-decoration: none; \" target='new'><img src=".$logo_dir."/".$logopath." width=\"15%\"></img></a>  </font>"; } else { echo "<font color='#4A708B' face='arial' ><img src=".$logo_dir."/".$logopath." width=\"15%\"></img>  </font>"; } ?> <br> <? } echo "<br>"; } } ?> Can someone help me debug this code...this is a search page where it searches the keyword typed in the mysql db and it limits 10 results per page...and at the bottom if there are more than 10 results it says next 10 and its a link but when it is clicked it goes to the code and says please type a search, here is the code can someone please help me with this I would really appreciate it. Code: [Select] <?php $page = $PHP_SELF; // Get the search variable from URL $var = @$_GET['search'] ; $searchtype = @$_GET['searchtype']; $isbn = "ISBN"; $school = "School"; $title = "Title"; $subject = "Subject"; $trimmed = trim($var); //trim whitespace from the stored variable // rows to return $limit=10; // check for an empty string and display a message. if ($trimmed == "") { echo "<p>Please enter a search...</p>"; exit; } // check for a search parameter if (!isset($var)) { echo "<p>We dont seem to have a search parameter!</p>"; exit; } //connect to your database $connect = mysql_connect("","]",]") or die("Not connected"); //specify database mysql_select_db("collegebooxboox") or die("could not log in"); if ($searchtype == ($title)) { // Build SQL Query $query = "select * from boox where name like \"%$trimmed%\" order by name"; // EDIT HERE and specify your table and field names for the SQL query } elseif ($searchtype == ($school)) { // Build SQL Query $query = "select * from boox where school like \"%$trimmed%\" order by school"; // EDIT HERE and specify your table and field names for the SQL query } elseif ($searchtype == ($isbn)) { // Build SQL Query $query = "select * from boox where isbn like \"%$trimmed%\" order by isbn"; // EDIT HERE and specify your table and field names for the SQL query echo "isbn"; } elseif ($searchtype == ($subject)) { // Build SQL Query $query = "select * from boox where subject like \"%$trimmed%\" order by subject"; // EDIT HERE and specify your table and field names for the SQL query } $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); // If we have no results, offer a google search as an alternative if ($numrows == 0) { echo "<h4>Results</h4>"; echo "<p>Sorry, your search: "" . $trimmed . "" returned zero results</p>"; echo "<p><a href=\"http://www.google.com/search?q=" . $trimmed . "\" target=\"_blank\" title=\"Look up " . $trimmed . " on Google\">Click here</a> to try the search on google</p>"; } // next determine if s has been passed to script, if not use 0 if (empty($s)) { $s=0; } // get results $query .= " limit $s,$limit"; $result = mysql_query($query) or die("Couldn't execute query"); // display what the person searched for echo "<p>You searched for: "" . $var . "" in "" . $searchtype ."" </p>"; // begin to show results set echo "Results "; $count = 1 + $s ; if ($searchtype = $title) { // now you can display the results returned while ($row= mysql_fetch_array($result)) { $title = $row["name"]; echo "$count. $title   </br><table width='297' border='1' align='center'> <tr> <td width='152'>Book Title:</td> <td width='129'>$row[name]</td> </tr> <tr> <td>Author:</td> <td>$row[author]</td> </tr> <tr> <td>ISBN#</td> <td>$row[isbn]</td> </tr> <tr> <td>Date Posted:</td> <td>$row[date]</td> </tr> <tr> <td>Posted By:</td> <td><a href='backpack.php' onclick='document['packback'].submit()'>$row[username]</a></td> </tr> <tr> <td>School:</td> <td>$row[school]</td> </tr> </table></br>"; $count++ ; } } elseif ($searchtype = $school) { // now you can display the results returned while ($row= mysql_fetch_array($result)) { $title = $row["school"]; echo "$count. $title" ; $count++ ; } } elseif ($searchtype = $subject) { // now you can display the results returned while ($row= mysql_fetch_array($result)) { $title = $row["subject"]; echo "$count. $title" ; $count++ ; } } elseif ($searchtype = $isbn) { // now you can display the results returned while ($row= mysql_fetch_array($result)) { $title = $row["isbn"]; echo "$count. $title" ; $count++ ; } } $currPage = (($s/$limit) + 1); //break before paging echo "<br />"; // next we need to do the links to other results if ($s>=1) { // bypass PREV link if s is 0 $prevs=($s-$limit); print " <a href=\"$PHP_SELF?s=$prevs&q=$var\"><< Prev 10</a>  "; } // calculate number of pages needing links $pages=intval($numrows/$limit); // $pages now contains int of pages needed unless there is a remainder from division if ($numrows%$limit) { // has remainder so add one page $pages++; } // check to see if last page if (!((($s+$limit)/$limit)==$pages) && $pages!=1) { // not last page so give NEXT link $news=$s+$limit; echo " <a href=\"$PHP_SELF?s=$news&q=$var\">Next 10 >></a>"; } $a = $s + ($limit) ; if ($a > $numrows) { $a = $numrows ; } $b = $s + 1 ; echo "<p>Showing results $b to $a of $numrows</p>"; ?> Hello all, I am working on a webpage which needs to be finished Friday so I am a bit stressing out, hence this post. I have made the following script: // Uitkomst van POST waardes echo"<pre>"; print_r($_POST); echo"</pre>"; // LET OP: De tabel "test_optie" is niet compleet gevuld en daarom werkt het script alleen als je start bij categorie 1. // Het is dus GEEN fout in de script, alleen de database is niet helemaal gevuld kostte me teveel tijd! echo" <html> <head> <style> select {float:left;width:250px;margin:0 5px 0 0;} </style> </head> <body> <form name='form' action='chainselect.php' method='post' /> <select name='veld1' onChange='document.form.submit()'> "; // Data opvragen $sql_categorie = mysql_query("SELECT * FROM plaatsnaam ORDER BY id") or die (mysql_error()); // Counter $a = 0; // Standaard geselecteerd echo"<option value='0' selected>Selecteer een plaats</option>"; while($row_categorie = mysql_fetch_array($sql_categorie)){ $a++; echo"<option value='$row_categorie[id]' ";if($_POST[veld1] == "$a"){echo"selected";}echo">$row_categorie[naam]</option>"; } echo" </select> <select name='veld2' onChange='document.form.submit()'> "; // Data opvragen $sql_rubriek = mysql_query("SELECT * FROM branche WHERE catid = '$_POST[veld1]'") or die (mysql_error()); $ant_rubriek = mysql_num_rows($sql_rubriek); // Huidige id veld2 om zodoende huidig veld te selecteren indien gewijzigd if(isset($_POST[veld2])){ $b = "$_POST[veld2]"; } // Als er geen data gevonden is dan de onderstaande option laten tonen. if($ant_rubriek <= 0){ echo"<option value='0'>-</option>"; } else{ // Standaard geselecteerd echo"<option value='0' selected>Selecteer een branche</option>"; while($row_rubriek = mysql_fetch_array($sql_rubriek)){ echo"<option value='$row_rubriek[id]' ";if($_POST[veld2] == "$row_rubriek[id]"){echo"selected";}echo">$row_rubriek[naam]</option>"; } } echo" </select> <select name='veld3' onChange='document.form.submit()'> "; // Data opvragen $sql_optie = mysql_query("SELECT * FROM filiaal WHERE catid = '$_POST[veld1]' AND rubid = '$_POST[veld2]'") or die (mysql_error()); $ant_optie = mysql_num_rows($sql_optie); // Huidige id veld3 om zodoende huidig veld te selecteren indien gewijzigd if(isset($_POST[veld3])){ $c = "$_POST[veld3]"; } // Als er geen data gevonden is dan de onderstaande option laten tonen. if($ant_optie <= 0){ echo"<option value='0'>-</option>"; } else{ // Standaard geselecteerd echo"<option value='0' selected>Selecteer een filiaal</option>"; while($row_optie = mysql_fetch_array($sql_optie)){ echo"<option value='$row_optie[id]' ";if($_POST[veld3] == "$row_optie[id]"){echo"selected";}echo">$row_optie[naam]</option>"; } } echo" </select> </form> </body> </html> "; ?> What I need now is the results shown linked to a page. U can see the dropdowns in action he www.inventar.nl/chainselect.php For example: In the first dropdown I select Groningen, in the 2nd drop I select Groningen, Restaurant and in the 3rd Groningen, Restaurant, Ni Hao Wok. This gives me the following: Quote Array ( [veld1] => 1 [veld2] => 2 [veld3] => 3 ) Now I have a page named nihao.php, this page needs to be linked to this array result. So if I do the above dropdowns it needs to open nihao.php Can anyone help me with this problem? I am really confused! Thanks in advance! Wheelie Hello. Say i want to view another user profile. I click on user name and i see the profile page. So how can i link user name to his profile? I have tried linking it to $id (this is where user id is stored in the database), but no luck. Thank you. |