PHP - Help With Links, Php And Mysql
Ok basically I'm working on a members page and I want the member's username to link to their profile. I've tried a couple of different things, none of which work. It's been a long time since I've done this type of thing so I can't remember how to do it. I also only want the row names (name, timezone, server, etc) to show ONCE instead of above every member's info. Any help would be greatly appreciated. Right now when you click on the username it just takes me to the page of the member I'm currently logged in as, instead of the member I clicked on.
Code: [Select] <?php echo "<table>"; $result = mysql_query("SELECT * FROM users WHERE looking='yes'"); while($row = mysql_fetch_array($result)) { echo "<tr><td>" . "NAME" . "</td><td>" . " " . "TIMEZONE" . "</td><td>" . " ". "SERVER" . "</td><td>" . " ". "CLASS" . "</td><td>" . " ". "RACE" . "</td><td>" . " ". "AA" . "</td><td>" . " ". "LEVEL" . "</td><td>" . " ". "EPIC" . "</td><td>" . " ". "CURRENT GUILD" . "</td><td>" . " ". "WILLING TO TRANSFER SERVERS" . "</td><tr>" ."<br>"; echo "<tr><td>" . "<a href=profile.php?ID=" . $row['ID'] . ">" . $row['user_name'] . "</a>" . "</td><td>" . " " . $row['timezone'] . "</td><td>" . " " .$row['server'] . "</td><td>" . " " .$row['class'] . "</td><td>" . " " . $row['race'] . "</td><td>" . " " . $row['aa'] . "</td><td>" . " " . $row['level'] . "</td><td>" . " " . $row['epic'] . "</td><td>" . " " . $row['guild'] . "</td><td>" . " " . $row['transfer'] . "</td></tr>"; } echo "</table>"; ?> Similar TutorialsI am trying to display certain MySQL data based off of what link is clicked. For example.. I want to display all the entries from 2009 when a link for 2009 is clicked; maybe like.. <a href="http://website.com/page?yr=09">2009</a> But I am having trouble doing so.. any help would be great! P.S. The years are in my database with only the last two numbers.. 10, 09, 08, etc. $result = mysql_query("select setlist_id, month, day, year, name, venue, location, label1, set1, set2, set3, encore, notes, photos, recording, poster from $database_table order by setlist_id DESC, year, month, day",$db) or die_now("Could not select setlists"); while($row = mysql_fetch_array($result)) { $the_id = $row["setlist_id"]; $the_month = $row["month"]; $the_day = $row["day"]; $the_year = $row["year"]; $the_name = $row["name"]; $the_venue = $row["venue"]; $the_location = $row["location"]; $the_label1 = $row["label1"]; $the_set1 = $row["set1"]; $the_set2 = $row["set2"]; $the_set3 = $row["set3"]; $the_encore = $row["encore"]; $the_notes = $row["notes"]; $the_photos = $row["photos"]; $the_recording = $row["recording"]; $the_poster = $row["poster"]; echo("<div class='date' id='date' tabindex='0'>" . "$the_month" . "." . "$the_day" . "." . "$the_year" . " - "); echo ($the_name != '') ? "" . "$the_name" . " - " : ''; echo("" . "$the_venue" . " - " . "$the_location" . "</div>"); echo("<div class='set'>" . "$the_label1" . ":<br /></div><div class='list'>" . "$the_set1" . "<br /></div>"); echo ($the_set2 != '') ? "<div class='set'>Set Two:<br /></div><div class='list'>" . "$the_set2" . "<br /></div>" : ''; echo ($the_set3 != '') ? "<div class='set'>Set Three:<br /></div><div class='list'>" . "$the_set3" . "<br /></div>" : ''; echo ($the_encore != '') ? "<div class='set'>Enco <br /></div><div class='list'>" . "$the_encore" . "<br /></sdiv>" : ''; echo("<div class='line'></div>"); echo nl2br("<div class='notes'>" . "$the_notes" . "</div>"); } When I replace the $result line with... $result = mysql_query("SELECT * FROM `$database_table` WHERE `year` = '09' order by setlist_id DESC, year, month, day",$db) or die_now("Could not select shows");... I get all the results from just 2009, which is what I want, but I want the results to depend on what link has been clicked. I hope I am making sense. 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... Hello, I have a quick question about methods for retrieving records from a mysql table and displaying them as a links For example, imagine I have three tables called countries, cities and city_info. I'd like to be able to select a country and have a list of that country's city names returned as links. I'd then like to be able to click on the link for London, say, and that would trigger a mysql query to retrieve the entry in city_info about London. Are there any functions that allow this? If anyone could point me in the right direction for further research I'd be grateful. Thanks. Hi there I'm trying to work out how I'd go about searching my database for URLs that have been submitted by users that are duplicates. Now this isn't as simple as http://www.example.com/something.php and http://www.example.com/something.php oh no! People have entered links such as http://www.example.com//something.php or http://www.example.com///something.php The script (I didn't write it) currently see's these links as unique, but they're not. They function exactly the same way. Anyone have any advice on how to weed these out? I was thinking maybe a straight forward LIKE '%//%' in the mySQL syntax, but this will bring all URLs up due to the http:// aspect of the link Any feedback would be appreciated! <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.
create table mimi (mimiId int(11) not null, mimiBody varchar(255) ); <?php //connecting to database include_once ('conn.php'); $sql ="SELECT mimiId, mimiBody FROM mimi"; $result = mysqli_query($conn, $sql ); $mimi = mysqli_fetch_assoc($result); $mimiId ='<span>No: '.$mimi['mimiId'].'</span>'; $mimiBody ='<p class="leading text-justify">'.$mimi['mimiBody'].'</p>'; ?> //what is next? i want to download pdf or text document after clicking button or link how to do that Hello everyone, Sorry if this has been answered but if it has I can't find it anywhere. So, from the begining then. Lets say I had a member table and in it I wanted to store what their top 3 interests are. Their$ row has all the usual things to identify them userID and password etc.. and I had a further 3 columns which were labled top3_1 top3_2 & top3_3 to put each of their interests in from a post form. If instead I wanted to store this data as a PHP Array instead (using 1 column instead of 3) is there a way to store it as readable data when you open the PHPmyadmin? At the moment all it says is array and when I call it back to the browser (say on a page where they could review and update their interests) it displays 'a' as top3_01 'r' as top3_02 and 'r' as top3_03 (in each putting what would be 'array' as it appears in the table if there were 5 results. Does anyone know what I mean? For example - If we had a form which collected the top 3 interests to put in a table called users, Code: [Select] <form action="back_to_same_page_for_processing.php" method="post" enctype="multipart/form-data"> <input name="top3_01" type="text" value="enter interest number 1 here" /> <input name="top3_02" type="text" value="enter interest number 2 here" /> <input name="top3_03" type="text" value="enter interest number 3 here" /> <input type="submit" name="update_button" value=" Save and Update! " /> </form> // If my quick code example for this form is not correct dont worry its not the point im getting at :) And they put 'bowling' in top3_01, 'running' in top3_02 and 'diving' in top3_03 and we catch that on the same page with some PHP at the top --> Code: [Select] if (isset($_POST)['update_button']) { $top3_01 = $_POST['top3_01']; // i.e, 'bowling' changing POST vars to local vars $top3_02 = $_POST['top3_02']; // i.e, 'running' $top3_03 = $_POST['top3_03']; // i.e, 'diving' With me so far? If I had a table which had 3 columns (1 for each interest) I could put something like - Code: [Select] include('connect_msql.php'); mysql_query("Select * FROM users WHERE id='$id' AND blah blah blah"); mysql_query("UPDATE users SET top3_01='$top3_01', top3_02='$top3_02', top3_03='$top3_03' WHERE id='$id'"); And hopefully if ive got it right, it will put them each in their own little column. Easy enough huh? But heres the thing, I want to put all these into an array to be stored in the 1 column (say called 'top3') and whats more have them clearly readable in PHPmyadmin and editable from there yet still be able to be called back an rendered on page when requested. Continuing the example then, assuming ive changed the table for the 'top3' column instead of individual colums, I could put something like this - Code: [Select] if (isset($_POST)['update_button']) { $top3_01 = $_POST['top3_01']; // i.e, 'bowling' changing POST vars to local vars $top3_02 = $_POST['top3_02']; // i.e, 'running' $top3_03 = $_POST['top3_03']; // i.e, 'diving' $top3_array = array($top3_01,$top3_02,$top3_03); include('connect_msql.php'); mysql_query("UPDATE members SET top3='$top3_array' WHERE id='$id' AND blah blah blah"); But it will appear in the column as 'Array' and when its called for using a query it will render the literal string. a r r in each field instead. Now I know you can use the 'serialize()' & 'unserialize()' funtcions but it makes the entry in the database practically unreadable. Is there a way to make it readable and editable without having to create a content management system? If so please let me know and I'll be your friend forever, lol, ok maybe not but I'd really appreciate the help anyways. The other thing is, If you can do this or something like it, how am I to add entries to that array to go back into the data base? I hope ive explained myself enough here, but if not say so and I'll have another go. Thanks very much people, L-PLate (P.s if I sort this out on my own ill post it all here) I have following piece of code below, and I would like to be able to express it pure SQL, something that could go into a .sql file :
$request_string='SELECT topic_forum_id FROM topic_table WHERE topic_id= 2014'; $query=database->prepare($request_string); $query->execute(); $data=$query->fetch(); $query->closeCursor(); $forum=$data['topic_forum_id']; $request_string='INSERT INTO post_table (post_topic,post_forum) VALUES (2014,:forum)'; $query=database->prepare($request_string); $query->bindValue(':forum',$forum,PDO::PARAM_INT); $query->execute(); $data=$query->fetch(); $query->closeCursor();Is it possible ? 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> I have some links created dynamicaly with php. But i have the following problem. When i am in the root folder ieg. localhost/myPage/index.php the links work fine because they link in a file named entry.php. but when i am in a folder ieg. localhost/myPage/users/authors.php and i click the links they try to go to localhost/myPage/users/entry.php and i want them to link not inside the folder but to the root folder localhost/myPage/entry.php. Hi! I have an odd problem... I inserted a flash file in a php doc, and basically what happens is that on some computers, the link does not work without the www extension ... by that i mean if people go to http://mysite.com they will not be able to click the banner but if they put http://www.mysite.com it works... Very odd as the link is part of the flash movie and it only happens on some computers not all ... anyone would have an idea as to what could cause this ? Alternativly what can I do with this piece of code that does not seem to do the trick either Code: [Select] <div class="subtitulo"><a href="http://hostelsuites.com/hostel-banner.php?Buenos+Aires+Hostel+Suites+Florida&id_hostel=30&idioma=3&id_banner=2"><?php echo ucfirst($lang["expanish"]) ?></a><br /> <br/></div> Many thanks for any help ! hi guys i need a bit of help, im trying to build a page which lists all orders in the database, and next to each order put in some links. i could do this fine, but i've now changed certain things and each user has certain permissions. my table is like this _users firstname | lastname | login | password | groupid _usergroups groupid | groupname _usergroup_permissions groupid | area | subarea all should be self explanitory, but in the permissions table `area` refers to the page (orders, customers, system) and `subarea` refers to the actual permission (Add, Edit, Delete, Manage) using the following script, im trying to: 1 - trying to get all the orders 2 - getting the groupid from the users table 3 - getting the permissions for the particular user's group $qry = mysql_query("SELECT o_id, sales_id, job_number, accounts_id, cust_id, status FROM `_orders` ORDER BY o_id DESC LIMIT 50") or die(mysql_error()); while ( $row = mysql_fetch_array($qry) ) { $sql1 = sprintf("SELECT `group` FROM `_users` WHERE `login` = '%s'", $_SESSION['user']); $qry1 = mysql_query($sql1); if(!$qry1){ die('could not query:' . mysql_error());} $sql2 = sprintf("SELECT `subarea` FROM `_usergroups_permissions` WHERE `gid` = '%s' AND `area` = 'Order' ", mysql_result($qry1, 0)); $qry2 = mysql_query($sql2); if(!$qry2){ die('could not query:' . mysql_error());} my group permissions are set to Add Edit and Delete, but there are additional privilages. what i want to happen is for each user that logs in, next to each order are links and depending on if they have the permission, the link will be shown. i tried using the following code in the while loop but it only showed upto the second if statement, and nothing else $link = "<a href='#'>View</a> | "; // show regardless of permissions (THIS WORKS if($racc == 0){$link .= "<a href='#'>Pick Up</a> | ";} // shown if the accounts id isn't set (THIS WORKS) if($qwerty == Edit ){ $links .="<a href='#' onclick='return false'>Edit</a> | ";} //Shown if the permission level says the user can Edit (THIS WORKS) if($qwerty == Delete ){ $links .="<a href='#' onclick='return false'>Delete</a> | ";} //Shown if the permission level says the user can Delete(DOESN'T WORK) if($qwerty == Approve ){ $links .="<a href='#' onclick='return false'>Approve</a> | ";} //Shown if the permission level says the user can Approve (DOESN'T WORKS) if($qwerty == Acceptance ){ $links .="<a href='#' onclick='return false'>Acceptance</a> | ";} //Shown if the permission level says the user can Acceptance (DOESN'T WORKS) I asked about this on another forum and they said its because $qwerty cant be everything and that i should look at using an array, unfortunately that has an undesired effect. so to summaraize...for me the page should look like order - salesman - customer - VIewLink | Addlink | Editlink | Deletelink | Approvelink but for someone who (for example) doesn't have the ADD and Delete permissions order - salesman - customer - VIewLink | Editlink | Approvelink . if NONE of that makes sence, i can provide links and try to explain again. but what i want is different links to be shown depending one what permissions a user has thanks for any help (sorry for waffling on a bit...its getting to that time of the day ) Jack Hey everyone, I'm relatively new to php and I have created a basic login page on my site. It checks whether someone is logged in by searching for a cookie. But I am wondering if there is a simple way to display content an link to only people who are logged in, and show user specific content based on who is logged it (much like forums - but not as complicated, just simple) Thank you and its very much appreciated There are different methods to catch links in <a> tag from a webpage. But surprisingly, with none of them I was successful to catch all links from e.g. http://www.amazon.com/Notebooks-Laptop-Computers/b/ref=sa_menu_lapnet6?ie=UTF8&node=565108 All links are captured except a series in the main area; e.g. http://www.amazon.com/s/ref=amb_link_85318851_3?ie=UTF8&node=565108&field-availability=-1&brand=acer&emi=ATVPDKIKX0DER&pf_rd_m=ATVPDKIKX0DER&pf_rd_s=center-6&pf_rd_r=1HET3VVW5SXMJ0SRKJVM&pf_rd_t=101&pf_rd_p=1291722382&pf_rd_i=565108 http://www.amazon.com/s/ref=amb_link_85318851_22?ie=UTF8&node=1232596011&brand=samsung&pf_rd_m=ATVPDKIKX0DER&pf_rd_s=center-6&pf_rd_r=1HET3VVW5SXMJ0SRKJVM&pf_rd_t=101&pf_rd_p=1291722382&pf_rd_i=565108 With my custom CMS I'm developing I have a menu structures type module where the admin can create a menu structures for their website. Inside the db is the links table and I'm trying to figure out what I can do if the link has an actual image. I created a field called link_image however I just thought of what if the link is apart of a sprite which would have most of the time 3 parts of the image (active, hover, normal) or whatever or has its own sprite. How should I handle this if I want to store this information in the database. In the MySQL help forum someone asked how to list out all the files in a directory. Another person gave the following code: Code: [Select] <?php $handle = opendir('PUT NAME OF YOUR DIR HERE'); while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo $file,'<br />'; } } closedir($handle); ?> I found this to be very helpful! However, is there a way to modify it so that if there are subdirectories, it will list those as hyperlinks so the code would run off of the subdirectory if you were to click that link? When I asked that question in the MySQL forum, I was told that it had nothing to do with PHP which I know. So that's why I am posting it here. Can anyone help? |