PHP - Collapsible Links
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. Similar TutorialsHi, I am trying to build a page that has a table inside a collapsible div. The table is dynamic, in that it is populated from a MySQL database. Now, the problem I have is that when I expand the table, I only get the very first row from the database. I know that they all need a unique ID so I am using the record ID from the db to dynamically assign each row a unique number, but it still does not work, I just get the first row. (They are all pulled, the div just does not show them all. ) So I played around a bit and moved the code inside the repeat region for the table, this was halfway there, except now I get a "show" link for EVERY row of the table and I have to click each one individually to show it's corresponding data. So I am at a loss. I am trying to make it so clicking one link at the top reveals the entire table, but it's just not working, so any help would be greatly appreciated. Here is what I am using so far... Javascript that handles show/hide part Code: [Select] <script language="javascript"> function toggleDiv(divid){ if(document.getElementById(divid).style.display == 'none'){ document.getElementById(divid).style.display = ''; }else{ document.getElementById(divid).style.display = 'none'; } } </script> The link Im using to show/hide the table Code: [Select] <a href="javascript:;" onmousedown="toggleDiv('t<?php echo $row_info['memID'] ?>);">Show/Hide</a> DIV Code: [Select] <div id="t<?php echo $row_info['memID'] ?>" style="display:none"> [table here] </div> Any help would be greatly appreciated... thanks in advance! Can anyone help me with how to create those lists which expand when you click a (+) .
I am looking to use this functionality : http://www.w3schools...mob_collapsible
However using my own CSS style.
I looked at the source code, unfortunately the code is just jammed together so it isn't immediately clear how it works, I thought too that I could find every semi-colon and do a line escape but I don't know / think that javascript / jquery follows the same end of line statement as php.
I'm just looking to have a rectangle that when pushed, another rectangle of the same width but different color / font "extends" below this one, pushing the other elements below, away.
If anyone would care to chime in I'd appreciate it, otherwise I'll scrutinize the javascript/jquery code, I haven't worked with either too much yet.
Thanks
Edited by moose-en-a-gant, 17 January 2015 - 07:22 AM. <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.
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 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? 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 replaced the display settings URLs permalink and .htaccess this is i write in .htaccess file RewriteEngine on RewriteCond %{HTTP_HOST} ^www.sportskevesti.co$ RewriteRule ^/?$ "http\:\/\/sportskevesti\.co" [R=301,L] RewriteRule ^vest/([0-9_]*).html$ index.php?opcija=permalink&=$1 [L] RewriteRule ^kategorija/([0-9a-zA-Z-_]*).html$ index.php?opcija=kategorija&kategorija_naziv=$1 [L] link is : http://sportskevesti.co/index.php?opcija=vest&permalink=evo-sta-se-desi-kad-srpskom-treneru-pukne-film-video and nothing happens what is wrong ? 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? I'm trying to make a link to an SQL database survive though page reloads, and it's not working. Connecting, I use this: function link_to_converted_database() { $link = mysqli_init(); if (!$link) { die('mysqli_init failed'); } if (!mysqli_options($link, MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT = 1')) { die('Setting MYSQLI_INIT_COMMAND failed'); } if (!mysqli_options($link, MYSQLI_OPT_CONNECT_TIMEOUT, 50)) { die('Setting MYSQLI_OPT_CONNECT_TIMEOUT failed'); } if (!mysqli_real_connect($link, 'redacted', 'redacted', 'redacted')) { die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); } comment( ' Success... ' . mysqli_get_host_info($link) ); if (mysqli_query($link,'USE conversion_database')) { comment("now using conversion_database."); } else { die('Conversion database unusable (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); } $_SESSION['mysql_link']=$link; echo "<!--\n"; var_dump($_SESSION['mysql_link']); echo "\n-->\n"; return(true); } Subsequent SQL commands work fine using $_SESSION['mysql_link'], and the var_dump returns: object(mysqli)#2 (17) { ["affected_rows"]=> int(0) ["client_info"]=> string(48) "mysqlnd 5.0.7-dev - 091210 - $Revision: 294543 $" ["client_version"]=> int(50007) ["connect_errno"]=> int(0) ["connect_error"]=> NULL ["errno"]=> int(0) ["error"]=> string(0) "" ["field_count"]=> int(0) ["host_info"]=> string(24) "192.168.1.101 via TCP/IP" ["info"]=> NULL ["insert_id"]=> int(0) ["server_info"]=> string(16) "5.1.48-community" ["server_version"]=> int(50148) ["sqlstate"]=> string(5) "00000" ["protocol_version"]=> int(10) ["thread_id"]=> int(194) ["warning_count"]=> int(0) } After a page changes, all my $_SESSION vars work fine except for $_SESSION['mysql_link']. It's still there, but SQL queries bomb, and var_dump returns: Warning: var_dump(): Property access is not allowed yet in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\voicereader\serverstate.php on line 595 Warning: var_dump(): Property access is not allowed yet in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\voicereader\serverstate.php on line 595 Warning: var_dump(): Couldn't fetch mysqli in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\voicereader\serverstate.php on line 595 Warning: var_dump(): Couldn't fetch mysqli in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\voicereader\serverstate.php on line 595 Warning: var_dump(): Couldn't fetch mysqli in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\voicereader\serverstate.php on line 595 Warning: var_dump(): Couldn't fetch mysqli in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\voicereader\serverstate.php on line 595 Warning: var_dump(): Couldn't fetch mysqli in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\voicereader\serverstate.php on line 595 Warning: var_dump(): Couldn't fetch mysqli in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\voicereader\serverstate.php on line 595 Warning: var_dump(): Couldn't fetch mysqli in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\voicereader\serverstate.php on line 595 Warning: var_dump(): Couldn't fetch mysqli in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\voicereader\serverstate.php on line 595 Warning: var_dump(): Couldn't fetch mysqli in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\voicereader\serverstate.php on line 595 Warning: var_dump(): Couldn't fetch mysqli in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\voicereader\serverstate.php on line 595 Warning: var_dump(): Couldn't fetch mysqli in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\voicereader\serverstate.php on line 595 Warning: var_dump(): Couldn't fetch mysqli in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\voicereader\serverstate.php on line 595 object(mysqli)#1 (17) { ["affected_rows"]=> NULL ["client_info"]=> NULL ["client_version"]=> int(50007) ["connect_errno"]=> int(0) ["connect_error"]=> NULL ["errno"]=> NULL ["error"]=> NULL ["field_count"]=> NULL ["host_info"]=> NULL ["info"]=> NULL ["insert_id"]=> NULL ["server_info"]=> NULL ["server_version"]=> NULL ["sqlstate"]=> NULL ["protocol_version"]=> NULL ["thread_id"]=> NULL ["warning_count"]=> NULL } There's got to be a way to save my SQL linkages so that I don't have to reconnect to the SQL database every time I want to see if new data has arrived, but this doesn't seem to be it. My PHP version is PHP 5.3.2.0. Thanks for any help. 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 I've been reading about trackbacks and pings but what I'm trying to do is a bit different. I'm trying to track a referral link. For example, I post this referral link http://www.my-site.com/3ji89 on youtube or a blog.. and that referral links to.. http://www.another-site.com in http://www.another-site.com is it possible to retrieve the referral link http://www.my-site.com/3ji89 ? Not youtube.com or the blog I posted the link on. 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 ! 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 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!! 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. Hello dear friends, Let say we have Code: [Select] $to = "gigi"; then we have link like this Code: [Select] mysite.com/file.php?id=$1 We can change it to new form by add rule at .htaccess codes Code: [Select] RewriteRule -(.*)\.htm file.php?id=$1 So that the link be like this Code: [Select] mysite.com/$to-$id.htm it will works , Now what if i want to make the link like this Code: [Select] mysite.com/$id/$to.htm what will be the .htaccess code in this way ??? 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 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. |