PHP - Links To The Same Page...
Hey all, I'm currently coding a Few Blacklists for my Website, in which I want to code it so I'll have all blacklists on one page so the URL would be like:
localhost/blacklist.php?user localhost/blacklist.php?staff I've got a Blacklist coded which all works well, just I've attempted using the $_GET function to change the code to the blacklist that they clicked on... <?php session_start(); include ("includes/config.php"); include ("includes/functions.php"); logincheck(); $Username = $_SESSION['username']; ?> <table width='50%' cellpadding='0' cellspacing='0' border='1' class='table' align='center'> <tr> <td class='header' align='center' colspan='4'>Other Blacklists:</td> </tr> <tr> <td align='center'><a href='?user' target='mainFrame'>User Blacklist</a></td><td align='center'><a href='?money' target='mainFrame'>Most Money</a></td><td align='center'><a href='?racewins.php' target='mainFrame'>Race Wins</a></td><td align='center'><a href='?racelose' target='mainFrame'>Race Loses</a></td> </tr> <tr> <td align='center'><a href='?miles' target='mainFrame'>Most Miles</a></td><td align='center'><a href='?fosbl' target='mainFrame'>Faster Or Slower</a></td><td align='center'><a href='?police' target='mainFrame'>Police Chase</a></td> </tr> </table> <br /> <table width='20%' cellpadding='0' cellspacing='0' border='1' class='table' align='center'> <tr> <td colspan='2' align='center' class='header'>User Blacklist:</td> </tr> <tr> <td align='center' class='omg' width='5%'>Num:</td><td align='center' class='omg' width='10%'>Username:</td> </tr> <?php if ($_GET['user']){ $Query = mysql_query("SELECT * FROM users WHERE userlevel = '1' OR userlevel = '5' ORDER BY rep DESC LIMIT 25"); for ($Place < 25; $This = mysql_fetch_object($Query);){ $Place = $Place+1; if ($This->username != $Username){ $Colour = "bgcolor=#424242"; }else{ $Colour = "bgcolor=#111111"; } print ("<tr><td width='5%' align='center' $Colour>$Place</td><td width='20%' align='center' $Colour><a href='profile.php?viewuser=".$This->username."'>$This->username</a></td></tr>"); } } ?> </table> <br /> Soon as I added the $_GET['user]{ it stopped showing the Blacklist completely. Sorry if it wasn't explained well, but hopefully you can catch what I'm trying to-do Thanks. Similar TutorialsQuesion: Show each movie in the database on its own page, and give the user links in a "page 1, Page 2, Page 3" - type navigation system. Hint: Use LIMIT to control which movie is on which page. I have provided 3 files: 1st: configure DB, 2nd: insert data, 3rd: my code for the question. I would appreciate the help. I am a noob by the way. First set up everything for DB: <?php //connect to MySQL $db = mysql_connect('localhost', 'root', '000') or die ('Unable to connect. Check your connection parameters.'); //create the main database if it doesn't already exist $query = 'CREATE DATABASE IF NOT EXISTS moviesite'; mysql_query($query, $db) or die(mysql_error($db)); //make sure our recently created database is the active one mysql_select_db('moviesite', $db) or die(mysql_error($db)); //create the movie table $query = 'CREATE TABLE movie ( movie_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, movie_name VARCHAR(255) NOT NULL, movie_type TINYINT NOT NULL DEFAULT 0, movie_year SMALLINT UNSIGNED NOT NULL DEFAULT 0, movie_leadactor INTEGER UNSIGNED NOT NULL DEFAULT 0, movie_director INTEGER UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (movie_id), KEY movie_type (movie_type, movie_year) ) ENGINE=MyISAM'; mysql_query($query, $db) or die (mysql_error($db)); //create the movietype table $query = 'CREATE TABLE movietype ( movietype_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT, movietype_label VARCHAR(100) NOT NULL, PRIMARY KEY (movietype_id) ) ENGINE=MyISAM'; mysql_query($query, $db) or die(mysql_error($db)); //create the people table $query = 'CREATE TABLE people ( people_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, people_fullname VARCHAR(255) NOT NULL, people_isactor TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, people_isdirector TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (people_id) ) ENGINE=MyISAM'; mysql_query($query, $db) or die(mysql_error($db)); echo 'Movie database successfully created!'; ?> ******************************************************************** *********************************************************************** second file to load info into DB: <?php // connect to MySQL $db = mysql_connect('localhost', 'root', '000') or die ('Unable to connect. Check your connection parameters.'); //make sure you're using the correct database mysql_select_db('moviesite', $db) or die(mysql_error($db)); // insert data into the movie table $query = 'INSERT INTO movie (movie_id, movie_name, movie_type, movie_year, movie_leadactor, movie_director) VALUES (1, "Bruce Almighty", 5, 2003, 1, 2), (2, "Office Space", 5, 1999, 5, 6), (3, "Grand Canyon", 2, 1991, 4, 3)'; mysql_query($query, $db) or die(mysql_error($db)); // insert data into the movietype table $query = 'INSERT INTO movietype (movietype_id, movietype_label) VALUES (1,"Sci Fi"), (2, "Drama"), (3, "Adventure"), (4, "War"), (5, "Comedy"), (6, "Horror"), (7, "Action"), (8, "Kids")'; mysql_query($query, $db) or die(mysql_error($db)); // insert data into the people table $query = 'INSERT INTO people (people_id, people_fullname, people_isactor, people_isdirector) VALUES (1, "Jim Carrey", 1, 0), (2, "Tom Shadyac", 0, 1), (3, "Lawrence Kasdan", 0, 1), (4, "Kevin Kline", 1, 0), (5, "Ron Livingston", 1, 0), (6, "Mike Judge", 0, 1)'; mysql_query($query, $db) or die(mysql_error($db)); echo 'Data inserted successfully!'; ?> ************************************************************** **************************************************************** MY CODE FOR THE QUESTION: <?php $db = mysql_connect('localhost', 'root', '000') or die ('Unable to connect. Check your connection parameters.'); mysql_select_db('moviesite', $db) or die(mysql_error($db)); //get our starting point for the query from the URL if (isset($_GET['offset'])) { $offset = $_GET['offset']; } else { $offset = 0; } //get the movie $query = 'SELECT movie_name, movie_year FROM movie ORDER BY movie_name LIMIT ' . $offset . ' , 1'; $result = mysql_query($query, $db) or die(mysql_error($db)); $row = mysql_fetch_assoc($result); ?> <html> <head> <title><?php echo $row['movie_name']; ?></title> </head> <body> <table border = "1"> <tr> <th>Movie Name</th> <th>Year</th> </tr><tr> <td><?php echo $row['movie_name']; ?></td> <td><?php echo $row['movie_year']; ?></td> </tr> </table> <p> <a href="page.php?offset=0">Page 1</a>, <a href="page.php?offset=1">Page 2</a>, <a href="page.php?offset=2">Page 3</a> </p> </body> </html> Hi, I need to get links from a web page and display them. User enters a url say abcxyz.com and all the links present on the page abcxyz.com will be displayed. How can i do this? Thanks. I am using this to get links from a page: preg_match_all("/href=(\"|')(.+?)(\"|')/", $opt, $matches); $links = $matches[2]; Once in a while I get a link that may look like this: site.com/"><span What can I do to make my regexp better so it doesn't get the html? Why this code dont work :S <?php echo ' <ul> <li'; if ($_SERVER['PHP_SELF'] == "kategorije.php") { echo ' id="current"'; } echo '><a href="kategorije.php"><span>Kategorije</span></a></li> </ul>'; ?> Checking if PHP_SELF is "kategorije.php" do not work, why, and what is solution ? I have two table in my database combined by using UNION, when it come to searching via search form, all data are retrieved as expected, but the problem come when i click the link that has the data from second table it redirecting to the page with first table details. Assume i have retrieved data using while loop and the UNION. while($search = $query->fetch()) {?> <div> <a href="pageone.php?po=<?php echo $search['pr_id'];?>">Read More...</a> </div> <?php }?> //the result become <a href="pageone.php?po=1">Read More...</a> <a href="pageone.php?pt=3">Read More...</a> //But what if data come from both first and second table in a database, i want the link become to be as <a href="pageone.php?po=1">Read More...</a> <a href="pagetwo.php?pt=3">Read More...</a> // any idea please
Hello, Im getting some data from a database. Im showing them in a php page. well its like this... Its a song and lyric site. Im displaying the whole song titles and lyrics when a user search. there's separate page to list all the songs available. Which displays all the TITLES of the songs. How can I make those Titles LINKS to view the lyrics when clicked?? A tutorial regarding a thing like this would be much helpful.. Thanks... The urls on my localhost look like a joke and I hope someone has a solution. I use $_SERVER['QUERY_STRING'] so the first number looks okay, it's that as I go up in page number to 2,3,4,5, etc it starts to look funky. The first time before the 2 for the second page is clicked it looks normal, the second time after the 2 is clicked they look screwy and as you can guess it keeps getting longer each time a number is clicked. I know that each time I go to a new page $_SERVER['QUERY_STRING'] changes and thats the problem. Here is the code I use Code: [Select] $qstring= htmlentities($_SERVER['QUERY_STRING']); // Make links to other pages if (($pages > 1) && ($start >= 0)) { // Add space and start a paragraph echo "\n<div id=\"page_num\"><p>"; // Determine what page the script is on $current_page = ($start/$display)+1; //If its not the first page make a previous button if ($current_page !=1) { echo '<a href="subject.php?'.$qstring.'&s=' . ($start-$display) . '&p=' . $pages . '">Previous</a> '; } //Make all the numbered pages for ($i = 1; $i <=$pages; $i++) { if ($i !=$current_page) { echo '<a href="subject.php?'.$qstring.'&s=' . (($display * ($i - 1))) . '&p=' . $pages . '">' . $i . '</a>'; } else { echo $i . ''; } } //End for loop // If its not the last page make a next button if ($current_page != $pages) { // $qstring = str_replace("($start + $display)&p=$pages", "", $qstring); echo '<a href="subject.php?'.$qstring.'&s=' . ($start + $display) . '&p=' . $pages. '">Next</a>'; } echo "</p>\n</div><!-- End page numbers div -->\n"; // Close paragraph } // End of "if (($pages > 1) && ($start >= 0))" links Is there a work around to this, a different way of doing it and if or switch or something. thanks Hi, I would like to display my master details page links to the details pages in three columns rather than a single column. Below is the do-while code I have thus far, and I am stuck. Could someone please mock up this code quick, because I know it is a simple syntax error somewhere. <?php do { echo "<table border='0'>"; for ($y=1; ; $y++) { echo "<tr>"; for ($x=1; $x<=3; $x++) { echo "<td align='left'><a href="plantdetails.php?recordID=echo $row_rsBotanicalA['PlantID'];">; echo $row_rsBotanicalA['BotanicalName']; </a></td>" } echo "</tr>"; } } while ($row_rsBotanicalA = mysql_fetch_assoc($rsBotanicalA)); echo "</table>"; ?> Well this is a tricky one for me. The script I've created is able to upload images to a server. The server, which I have no control over, generates a random name. It uses Javascript and flash. As a result the links to these images are not within the source code. I suppose the question is, is there a way to still grab these links? I'm familiar with cURL and I was thinking about using something like (CURLOPT_FOLLOWLOCATION) but I'm wondering if that would just look at the source code for links as well? Has anyone had this problem before? <html> <?php $id = $_GET['id']; $dbusername="web148-matt"; $dbpassword="matt"; $dbdatabase="web148-matt"; mysql_connect(localhost,$dbusername,$dbpassword); @mysql_select_db($dbdatabase) or die( "Unable to select database"); mysql_query("UPDATE count SET clicks=clicks+1 WHERE id='$id'"); $sql = mysql_query("SELECT link FROM count WHERE id='$id'"); $fetch = mysql_fetch_row($sql); $result = mysql_query("SELECT * FROM count"); while($row = mysql_fetch_array($result)) { echo "<a href=" .$row['link']. ">Link</a>"; } ?> <a href='http://www.google.com'>Google</a> <a href='/index.php?id=2'>link2</a> </html> So I have been working on my website for a while which all is php&mysql based, now working on the social networking part building in similar functions like Facebook has. I encountered a difficulty with getting information back from a link. I've checked several sources how it is possible, with title 'Facebook Like URL data Extract Using jQuery PHP and Ajax' was the most popular answer, I get the scripts but all of these scripts work with html links only. My site all with php extensions and copy&paste my site links into these demos do not return anything . I checked the code and all of them using file_get_contents(), parsing through the html file so if i pass 'filename.php' it returns nothing supposing that php has not processed yet and the function gets the content of the php script with no data of course. So my question is that how it is possible to extract data from a link with php extension (on Facebook it works) or how to get php file executed for file_get_contents() to get back the html?
here is the link with code&demo iamusing: http://www.sanwebe.c...-php-and-jquery
thanks in advance.
Some code from my pages ,
Page1 ( Redirecting page )
<html> <title>login_redirect.</title> body> <form name="redirect" action="http://mysite/page2.php" method="post"> <input type="hidden" name="mac" value="$(mac)"> </form> <script language="JavaScript"> <!-- document.redirect.submit(); //--> </script> </body> </html>Page 2 ( select product ) <?php session_start(); ini_set('display_errors',1); error_reporting(E_ALL); include '../lib/config.php'; include '../lib/opendb.php'; // get user mac adres from redirect post page1 $_SESSION['macid'] = $_POST['mac']; // set $macid for other use ( maybe not needed, am learning ) $macid = $_SESSION['macid']; // echo $macid does show mac adress, so variable is not empty here if (!empty($_POST["submit"])) { $product_choice = $_POST['accounttype']; $query= "SELECT AccountIndex, AccountCost, AccountName FROM AccountTypes WHERE AccountIndex='$product_choice'"; $result = mysql_query($query) or die('Query failed. ' . mysql_error()); while($row = mysql_fetch_array($result)) { $_SESSION['AccountIndex'] = $row['AccountIndex']; $_SESSION['AccountCost'] = $row['AccountCost']; $_SESSION['AccountName'] = $row['AccountName']; } header('Location: page3.php'); } // did leave out the other/html/form stuff herePage 3 ( show Session variables ) <?php ini_set('display_errors',1); error_reporting(E_ALL); session_start(); print_r($_SESSION); ?>Now, on page 3 i do see the right session varables, only the "macid" is empty. why ? Hi... I am really new to this. Please help me with this... as part of a gallery, I have categories and a thumbnail. As of now the title/link to the gallery shows up on the side of the thumbnail. How can I place the link below the thumbnail? Here is the code Code: [Select] $result_array[] = "<a href='viewgallery.php?cid=".$row[0]."'>".$row[1]."<img src='/photos/categoryimages/category".$row[0].".jpg' border=0 height='133px' width='200px' </a>"; Thank you for your help... I am trying to create a link with an ID from one of my MySQL records. $data = mysql_query("SELECT * FROM USERS"); $info = mysql_fetch_array($data); echo "<a href=a.php?'$info['id']'>hello</a>"; is what I am attempting, but this does not work. Any ideas? ok so im trying to make a news website and i want to be able to include links inside me headline like most news website they talk about the stuff and include some links along the way how would i manage to do that. I would put all my story in the Release textarea Code: [Select] <form class="createheadline" action="createrelease.php" method="post" enctype="multipart/form-data"> <table> <tr> <td></td> <td><?php echo $msg;?></td> </tr> <tr> <td>Author:</td> <td><input type="text" name="author" size="30"/></td> </tr> <tr> <td>Date:</td> <td><input type="text" name="date" /></td> </tr> <tr> <td>Title:</td> <td><input type="text" name="title" size="30"/></td> </tr> <tr> <td>Main Picture</td> <td><input type="file" name="picture" /></td> </tr> <tr> <td>Release:</td> <td><textarea name="release" cols="75" rows="27"></textarea></td> </tr> <tr> <td></td> <td><input type="submit" name="submitbtn" /></td> </tr> </table> </form> Hi, I have a string which contains a mix of Content and anchor links Example: //Example $strContent = 'I am some <a href="/content.htm">Content</a> here, but I could have <a href="/link.php">a Link</a> <a href="http://www.example.com">Followed by another</a> Link, Mix external and not.'; I basically want to programatically pull out all of the Anchor links, and have an array of such Array('/content.htm', '/link.php', 'http://www.example.com'); Help me please. Got a brain freeze as its Friday Afternoon Hi, I've been working on making my own FAQ system for my site with PHP & MySQL, I have the SQL displaying properly on the page but I cant seem to figure out how to make it so when the page loads just the questions show and when a question is clicked the answer shows below it. I've read a number of tutorials and when I do get it to work it will only show the answer to the first question when the link is clicked. Here is the code I'm using to display the info from the database: Code: [Select] <div id="faqSQL"> <?php foreach($result as $option) { ?> <div class="faq-question"><?php echo wordwrap($option['faqquestion'], 100, "\n", false);?></div> <div class="faq-answer"><?php echo wordwrap($option['faqanswer'], 100, "\n", false);?></div> <?php } ?> </div> If anyone can help it would be much appreciated. Hi all, Im sorry if this is in the wrong section. But nonetheless, I use php to display my news: I.e - news.php?id=1 that displays all the news on that id. What I want to know is using php how can I get the URL from news.php?id=1 too something like /news/titleofthestory ? Hope I've given enough detail. Thanks!! I am trying to get the output for a mysql query to be displayed in colums. I have it where it does this but it goes from left to right. I would rather it go from top to bottem, it would look better this way. I will also need it to brake into sevral pages when there are a certain amout of entrys shown. If you know of a good how to on that let me know please. The other problom that I am having is to make the output a link. I was able to do this before I attemped to devide everything but if I add in what I had before it comes back with no data. Here's what I have now that put shows the data from left to right in 2 colums. Code: [Select] <?php include"scripts/connect.php" ; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM movies WHERE type LIKE 'movie' ORDER BY title"; if(mysql_query($query)) { $result=mysql_query($query); $num=mysql_numrows($result); } for($i=0; $i<$num; $i++) { if($i%2==0){ echo "<tr><td>"; } else{ echo "<td>"; } print mysql_result($result,$i,"title"); if ($i%2==0){ echo "</td>"; } else{ echo "</td>"; } } echo "</tr>"; ?> Thanks in advance |