PHP - Previous Directory Issue
Hi , i read many articles and tried many things before asking but i came to a dead end. My problem is very simple (or at least i believe so).
In the main directory \httpdocs there is this file we call "header.php" and another file we call "article.php".
So the code of the article is very simple:
<?php include("header.php"); echo "bla bla bla\n"; ?> Similar TutorialsHey Guys, I posted a topic titled "Error while executing PHP script for Like/Dislike button" in the forum but am unable to access the topic. The link to the topic is http://www.phpfreaks.com/forums/index.php?topic=353877.new;topicseen#new. Kindly help me as I an unable to locate/search for it. Thank you. Here's my directory read code.. $dir = "renamed/"; $fileCount = 0; // Open the directory, and proceed to read its contents if (is_dir($dir)) { if ($dh = opendir($dir)) { while (false !== ($file = readdir($dh))) { $fileCount++; echo $file . "<BR>"; } closedir($dh); } } That part works 99%, for some reason the echo $file . "<BR>"; part echos two weird things. A singe dot and two dots as displayed below. R_334499.jpg R_334488.jpg R_334510.jpg R_334479.jpg R_334494.jpg R_334476.jpg R_334480.jpg R_334507.jpg R_334482.jpg R_334489.jpg R_334498.jpg .. R_334509.jpg R_334511.jpg R_334513.jpg R_334483.jpg R_334514.jpg R_334484.jpg R_334504.jpg R_334506.jpg R_334475.jpg R_334502.jpg R_334490.jpg R_334486.jpg R_334477.jpg R_334492.jpg R_334487.jpg R_334493.jpg . R_334496.jpg R_334500.jpg R_334485.jpg R_334497.jpg R_334491.jpg R_334481.jpg R_334508.jpg R_334505.jpg R_334501.jpg R_334503.jpg R_334495.jpg R_334478.jpg R_334512.jpg Any idea where it's getting the .. and the . from? not sure if this is the right place to post about help with FTP clients but i see an FTP thread stickied here and no other forums seems more appropriate. please move if im in the wrong place.
we have a reseller hosting account with crocweb. their service has been great the first few months. we recently hit a hiccup where for the last few days we have difficulty ftp-ing to the server. nothing that i can think of was changed on our side. the problem just started spontaneously from our perspective. i am in NY and my partner in NC. on the same night we both had trouble getting or staying connected via ftp. i was using WINSCP and he tried FileZilla, the built-in Mac FTP client, and CyberDuck. we could connect but sometimes while surfing directories, we would get a FAIL TO RETRIEVE DIRECTORY LISTING error. or the ftp client would timeout.
the problem seems to have cleared up for my colleague but continues sporadically for me. crocweb support was very quick to say they could not replicate the problem but insisted it has to be client side so they refuse to investigate any further. their "solution" was for me to switch ftp programs. theyve told me its my problem and they wont assist with it.
i did download and try filezilla both in passive and active mode. same problems. tried both modes in WINSCP too and still problems. not sure what else to do at this point. have been googling the topic but no luck figuring this out. from what ive read, it frequently can be a setting in the ftp program that (such as switching to passive mode) can be the fix. tried whatever ive found. also have read that there could be a server configuration problem. port not configured properly or something. i really dont know.
anyone have any ideas what i can do?
Hi guys, I've been working on a script for a while now, and I'm sure it doesn't look great and all, and it's probably really messed up.. But right now I've finally got it working! There's only 1 thing I'd really like to add.. Searching through & listing of remote directories! The directories I'm trying to list have directory listings enabled, and I think it *should* be possible. I just have no clue how. Here's my current code in a beautiful mix of HTML and PHP: <? $border_size = "0"; function returner($what) { $what=explode("/",$what); $tps=count($what); $what=$what[$tps-1]; return $what; } $page_url= ""; $home_url=returner(__FILE__); if(isset($_GET['q'])) { $qtext=$_GET['q']; } else { $qtext=""; } function getdirsize($directory, $format=FALSE) { $size = 0; if(substr($directory,-1) == '/') { $directory = substr($directory,0,-1); } if(!file_exists($directory) || !is_dir($directory) || !is_readable($directory)) { return -1; } if($handle = opendir($directory)) { while(($file = readdir($handle)) !== false) { $path = $directory.'/'.$file; if($file != '.' && $file != '..') { if(is_file($path)) { $size += filesize($path); } elseif(is_dir($path)) { $handlesize = getdirsize($path); if($handlesize >= 0) { $size += $handlesize; } else { return -1; } } } } closedir($handle); } if($format == TRUE) { if($size / 1048576 > 1) { return round($size / 1048576, 1).' MB'; } elseif($size / 1024 > 1) { return round($size / 1024, 1).' KB'; } else { return round($size, 1).' bytes'; } } else { return $size; } } if(isset($_GET['type'])){ $type=$_GET['type']; } else { $type="new"; } $textures=0; $models=0; $avatars=0; $seqs=0; $sounds=0; foreach (glob("textures/*.jpg") as $texture){ $textures++; } foreach (glob("models/*.zip") as $model){ $models++; } foreach (glob("avatars/*.zip") as $avatar){ $avatars++; } foreach (glob("seqs/*.zip") as $seq){ $seqs++; } foreach (glob("sounds/*.zip") as $sound){ $sounds++; } ?> <!DOCTYPE html> <html> <head> <title>ObjectPath Search</title> <style type="text/css"> #wrapper { width: 850px; margin: 30px auto 30px auto; padding: 10px; } body { color:#C6C6C6; background:#1E1E1E; /* margin:0; padding:0; */ overflow-x:hidden; } #tabs { font: 85% "Trebuchet MS", sans-serif; } .left { float: left; } .right { float: right; } a:link, a:visited, a:active { color: #3DB015; text-decoration: none; } a:hover { color: #00E0FF; } h2 { color: #3DB015; padding-bottom: 0.2em; font-size: 110%; } ul#icon {margin: 0; padding: 0;} ul#icon li {margin: 1px; position: relative; padding: 1px 0; cursor: pointer; float: left; list-style: none;} ul#icon span.ui-icon {float: left; margin: 0 1px;} </style> <link type="text/css" href="http://objects.jk-hosting.com/search/css/black-tie/jquery-ui-1.8.2.custom.css" rel="stylesheet" /> <script type="text/javascript" src="http://objects.jk-hosting.com/search/js/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="http://objects.jk-hosting.com/search/js/jquery-ui-1.8.2.custom.min.js"></script> <script type="text/javascript"> function formHandler(form){ var URL = document.form.site.options[document.form.site.selectedIndex].value; window.location.href = URL; }; $(function(){ // Tabs $('#tabs').tabs(); }); </script> </head> <body> <div id="wrapper"> <div id="tabs"> <!-- Tabs start --> <ul> <li><a href="#tab-search">Search</a></li> <li><a href="#tab-list">List Objects</a></li> <li><a href="#tab-info">OP info</a></li> </ul> <div id="tab-search"><!-- Searchtab start --> Please enter a string to search for, and choose a folder to search in. <br /><br /> <form name="Search"> <input type='hidden' value='search' name='type'> <input value='<? print $qtext; ?>' type='text' name='q'> <select name='map'> <option selected='selected' value='models'>Models</option> <option value='avatars'>Avatars</option> <option value='textures'>Textures</option> <option value='seqs'>Seqs</option> <option value='sounds'>Sounds</option></select> <input type='submit' value='Search'> </form> </div> <!-- Searchtab end --> <div id="tab-list"><!-- Listtab start --> Please pick a folder to browse. <br /><br /> <form name="form"> <select name="site" onChange="javascript:formHandler()"> <option value="#">Look in folder...</option> <option value="<? print $page_url; ?>?type=list&map=models">Models</option> <option value="<? print $page_url; ?>?type=list&map=avatars">Avatars</option> <option value="<? print $page_url; ?>?type=list&map=textures">Textures</option> <option value="<? print $page_url; ?>?type=list&map=seqs">Seqs</option> <option value="<? print $page_url; ?>?type=list&map=sounds">Sounds</option> </select> </form> </div> <!-- Listtab end --> <div id="tab-info"><!-- Info tab start --> The OP currently contains: <br /><br /> <table> <tr><td><b><? echo $models; ?></b></td> <td>Models</td></tr> <tr><td><b><? echo $avatars; ?></b></td> <td>Avatars</td></tr> <tr><td><b><? echo $textures; ?></b></td> <td>Textures</td></tr> <tr><td><b><? echo $seqs; ?></b></td> <td>Seqs</td></tr> <tr><td><b><? echo $sounds; ?></b></td> <td>Sounds</td></tr> </table> </div> <!-- Info tab end --> </div> <!-- Tabs end --> </div> <!-- Start PHP generated content --> <? if($type=="search" || $type=="list") { $M=$_GET['map']; if($type=="search") { $Q=$_GET['q']; $empty="Nothing found with <b>\"" . $Q . "\"</b> in it's name.<br />\nPlease make a more general search query, or try a different folder.\n\n"; } else { $Q=""; $empty='This folder is empty'; } if($M=="textures") { $ext="jpg"; } else { $ext="zip"; } $i=0; print "<hr>\n"; $endfile=array(); $endsize=array(); $endsize2=array(); foreach (glob($M."/*".$Q."*.".$ext) as $filename) { $filename = explode(".", $filename); $filename=$filename[0]; $filename = explode("/", $filename); $filename=$filename[1]; $i++; $endfile[$i]=$filename; if($ext=="jpg") { $endfile[$i]="<a name='".$endfile[$i]."' href='".$pageurl."?type=view&name=".$endfile[$i]."&folder=".$M."&from=".$type."&addon=".$Q."'>".$endfile[$i]."</a>"; } $endsize[$i]=$size; $endsize2[$i]=$size2; } if($i != 1) { print "<b>".$i."</b> items were found.\n<hr>\n"; } else { print "<b>".$i."</b> item was found.\n<hr>\n"; } echo("<table width='100%' border='" . $border_size . "' cellspacing='0' cellpadding='0' >\n"); if($i!=0) { for ($t = 1; $t < $i; $t++) { $thumbfile = $M."/".$endfile[$t].'.jpg'; if(file_exists($thumbfile)) { $thumbnail = "<a name='".$endfile[$t]."' href='".$page_url."?type=view&name=".$endfile[$t]."&folder=".$M."&from=".$type."&addon=".$Q."'><ul id='icon'><li class='ui-state-default ui-corner-all' title='".$endfile[$t]."'><span class='ui-icon ui-icon-image'></span></li></ul></a>"; } else { $thumbnail = ""; } if($t=="1") { echo("<tr><td width='10%'>Number</td><td width='3%'><ul id='icon'><li class='ui-state-default ui-corner-all' title='".$endfile[$t]."'><span class='ui-icon ui-icon-image'></span></li></ul></td><td width='60%'>Name</td></tr>\n"); } echo("<tr><td>" . $t . "</td><td>".$thumbnail."</td><td>" . $endfile[$t] . "</td></tr>\n"); flush(); } $thumbfile = $M."/".$endfile[$t].'.jpg'; if(file_exists($thumbfile)) { $thumbnail = "<a name='".$endfile[$t]."' href='".$page_url."?type=view&name=".$endfile[$t]."&folder=".$M."&from=".$type."&addon=".$Q."'><ul id='icon'><li class='ui-state-default ui-corner-all' title='".$endfile[$t]."'><span class='ui-icon ui-icon-image'></span></li></ul></a>"; } else { $thumbnail = ""; } echo("<tr><td>" . $t . "</td><td>".$thumbnail."</td><td>" . $endfile[$t] . "</td></tr>\n"); } print "</table>\n"; if($i=="0") { print $empty; } } elseif($type=="view") { $filename=$_GET['name']; $folder=$_GET['folder']; if($_GET['from']=="list"){ $addon="?type=list&map=".$folder."#".$filename; } if($_GET['from']=="search"){ $addon="?type=search&q=".$filename."&map=".$folder."#".$filename; } print"<center><a href='".$home_url."'>Home</a></center>"; print "<hr>\n<center><img src='".$folder."/".$filename.".jpg'></img></center>\n<hr>\n<br />\n<a href='".$page_url."".$addon."'>Previous Page</a>\n"; } $htmlshow=""; if($_GET['type']=="returnOPfile") { if(isset($_GET['split'])) { $splitter=$_GET['split']; } else { $splitter=" | "; } if(isset($_GET['html'])) { $htmlshow="<br />"; } foreach (glob("textures/*.jpg") as $texture){ if(isset($_GET['size'])) { $size=$splitter.filesize($texture); } $texture = explode("/", $texture); $texture=$texture[1]; print "textures".$splitter.$texture.$size."\n".$htmlshow; } foreach (glob("models/*.zip") as $model){ if(isset($_GET['size'])) { $size=$splitter.filesize($model); } $model = explode("/", $model); $model=$model[1]; print "models".$splitter.$model.$size."\n".$htmlshow; } foreach (glob("avatars/*.zip") as $avatar){ if(isset($_GET['size'])) { $size=$splitter.filesize($avatar); } $avatar = explode("/", $avatar); $avatar=$avatar[1]; print "avatars".$splitter.$avatar.$size."\n".$htmlshow; } foreach (glob("seqs/*.zip") as $seq){ if(isset($_GET['size'])) { $size=$splitter.filesize($seq); } $seq = explode("/", $seq); $seq=$seq[1]; print "seqs".$splitter.$seq.$size."\n".$htmlshow; } foreach (glob("sounds/*.zip") as $sound){ if(isset($_GET['size'])) { $size=$splitter.filesize($sound); } $sound = explode("/", $sound); $sound=$sound[1]; print "sounds".$splitter.$sound.$size."\n".$htmlshow; } } ?> <!-- End PHP generated content --> </body> </html> So right now my question to you PHP freaks is, can you please help me edit my script so I can search through a remote directory? *This* is one of the directories I wish to be able to search through & list.. Thanks in advance. Edit; It might help if you know what the site currently looks like. *Click* i have made an delete files script which works for only one directory but not sub directory so i want to delete files of same extention from directory and subdirectory. My current code is Code: [Select] <? $dir = 'hmm/'; function scanr($dir){ $arr = glob($dir.'/*.jpg'); foreach($arr as $vv){ //check if $vv is a file if(is_file($vv)){ //if file, get the filename $vx=explode('/',$vv); $file=$vx[count($vx)-1]; // if no extension delete the file unlink($vv); // print the deletion message echo $vv." deleted!<br>";}else{ // if $vv is a dir then scan it again for files scanr($vv); }} } scanr($dir); ?> I'm trying to echo the directory and sub directory only. I am not looking to show the files contained - only folders. I'm trying to create a function where you specify the $points it will then do some mathematical stuff with the $points (explain later) an return an array containing the $rank and $level. The mathematical stuff: It starts at 99 and when it reaches +199 it changes the key of the array. I'm not sure how to describe this theirfore i'll just provide examples: Example 1: If $points <= 99 It will return an array containing $ranks[0] and $levels[0], would be the following: return array('Peon', 0); Example 2: If $points >= 100 && $points <= 299 It will return an array containing $ranks[1] and $levels[1], would be the following: return array('Grunt', 1); Example 3: If $points >= 300 && $points <= 499 It will return an array containing $ranks[2] and $levels[2], would be the following: return array('Berserker', 2); etc.. until it reaches the 7th key of the $ranks/$levels array Heres my code: <?php function rank($points){ //their are 0-7 levels $levels = range(0, 7); //7 ranks $ranks = array('Peon', 'Grunt', 'Berserker', 'Tauren', 'Spirit Walker', 'Wind Rider'); for(...) { return array($rank, $level); } } ?> I have rows being generated in a foreach loop. I need to find the time in the row before it (or maybe after it if my logic is screwed up) to see if the times are equal. If they are equal, I need to see if the next row after that is equal. If it is not equal then stop. mysql user id time action 1 5 bought 1 5 purchased 1 5 sold 1 4 created Code: [Select] foreach($newsfeed as $k => $news) { if ($news['time'] == $news['time'] of $k--) { echo " you bought purchased and created"; } else { echo $news['action']; } } How can I get the next four and previous four rows? Here is what I have and it isn't working at at all. $q1 = Mysql::query("SELECT id, file, dir FROM photos WHERE id > $id AND album = '$al' ORDER BY id ASC LIMIT 4"); $q2 = Mysql::query("SELECT id, file, dir FROM photos WHERE id < $id AND album = '$al' ORDER BY id DESC LIMIT 4"); Hi all, I have a fairly simple problem, but i cannot get to it. I have a page, that displays one (1) record at the time, and I want to have forward and back buttons (links) at the top and bottom of the page. Can anyone help me with that??? Here is a part of my code. Code: [Select] <form method="get"> <table border="0" width="90%" cellpadding="2" cellspacing="2" align="center"> <tr><td align="center"> Select first letter or kind of the story: <input type="hidden" name="link" value="stories.php"> <input type="hidden" name="Pripadnost" value="3"> <select name="letter" onchange="this.form.submit()"> <?PHP $letter = trim($_REQUEST["letter"]); ?> <option value="Sve" <?PHP echo $letter == "All" ? " selected " : "" ; ?>>All</option> <?PHP include_once ("/includes/databaseMySQL.php"); mysql_set_charset('utf8'); $SQL = "Select distinct ucase(left(title,1)) as sl FROM tblStoryes order by sl"; $rs_data = mysql_query($SQL) or die(mysql_error()); while ($row_data = mysql_fetch_assoc($rs_data)) { ?> <option value="<?PHP echo $row_data["sl"]; ?>"<?PHP echo $letter == $row_data["sl"] ? " selected " : "" ; echo ">".$row_data["sl"] ;?></option> <?PHP // ****************** Listed all the first letters of the titles into a drop box. *********************** // } ?> </select> Bosnian <input type="checkbox" name="Bosnian " <?PHP echo isset($_REQUEST["Bosnian "]) ? "checked=checked" : "" ;?> onclick="this.form.submit()" /> Turkish <input type="checkbox" name="Turkish " <?PHP echo isset($_REQUEST["Turkish "]) ? "checked=checked" : "" ;?> onclick="this.form.submit()" /> Arabian <input type="checkbox" name="Arabian " <?PHP echo isset($_REQUEST["Arabian "]) ? "checked=checked" : "" ;?> onclick="this.form.submit()" /> </td></tr> </table> <table border="0" width="90%" cellpadding="2" cellspacing="2" align="center"> <?PHP $id = -1; $rs_data = mysql_query("Select max(id) as maxid from tblStories WHERE aktivno = True") or die(mysql_error()); $row_data = mysql_fetch_assoc($rs_data); $maxid = (int) $row_data["maxid"]; // ****************** Found the largest ID from the table. *********************** // $SQL = "SELECT * FROM tblStories WHERE aktivno = True "; if ( strlen($letter) < 3 && strlen($letter) > 0 ) { $SQL = $SQL . " and ucase(left(`title`, 1)) = '" . $Letter . "'"; } $lang = 0; $lang = $lang + isset($_REQUEST["Bosnian"]) * 4; $lang = $lang + isset($_REQUEST["Turkish"] ) * 2; $lang = $lang + isset($_REQUEST["Arabian"] ); switch ($lang) { case 6: // bos i tur $SQL = $SQL . " and ( Bosanski = 1 or Turski = 1 ) "; break; case 5: // bos i ar $SQL = $SQL . " and ( Bosanski = 1 or Arapski = 1) "; break; case 4: // bos $SQL = $SQL . " and Bosanski = 1 "; break; case 3: // tur i ar $SQL = $SQL . " and ( Turski = 1 or Arapski =1) "; break; case 2: // tur $SQL = $SQL . " and Turski = 1 "; break; case 1: // ar $SQL = $SQL . " and Arapski =1 "; break; } if (trim($_REQUEST["DBid"]) <> "" or $_REQUEST["DBid"] > 0) $SQL = $SQL . " and id > " . trim($_REQUEST["DBid"]) ; $SQL = $SQL . " LIMIT 1"; //order by naslov $rs_data = mysql_query($SQL) or die(mysql_error()); echo "<!--" . $SQL . " : Jezik je:" . $lang . "-->"; while ($row_data = mysql_fetch_assoc($rs_data)) { $id = (int) $row_data["ID"]; ?> <tr> <td align="center" colspan=3> <h3><?PHP echo $row_data["Title"];?> </h3> </td> </tr> <tr> <td width=20%> </td> <td align="justify" width=60%> <?PHP echo $row_data["tekst"]; // tekst = text, but not keyword ?> </td> <td width=20%> </td> </tr> <?PHP } ?> </table> <p> <?PHP // ****************************** HEEEEELLLLPPPPPP ******************************* // ?> <table border="0" width="90%" cellpadding="1" align="center"> <tr> <td align="center"><a href="?DBid=1<?PHP foreach($_REQUEST as $arr => $elem){ if ( $arr != "DBid") echo "&" . $arr . "=" . $elem; } ?>"> <<</a></td> <td align="center"><a href="?DBid=<?PHP echo $_REQUEST["id"]; foreach($_REQUEST as $arr => $elem){ if ( $arr != "DBid") echo "&" . $arr . "=" . $elem; } ?>" ><</a></td> <?PHP if ( $maxid <= $id ) { ?> <td align="center">></td> <td align="center">>></td> <?PHP } else {?> <td align="center"><a href="?DBid=<?PHP echo $id ; foreach($_REQUEST as $arr => $elem){ if ($arr != "DBid") echo "&" . $arr . "=" . $elem; } ?>">></a></td> <?PHP if ( ($id + 9) < $maxid ) { ?> <td align="center"><a href="?DBid=<?PHP echo $id+10 ; foreach($_REQUEST as $arr => $elem){ if ($arr != "DBid") echo "&" . $arr . "=" . $elem; } ?>">>></a></td> <?PHP } else {?> <td align="center">>></td> <?PHP }?> <?PHP }?> </tr> </table> </form> Dear All I am seriously stuck up I am displaying a products for shoppoing cart (using MYSQL and PHP) then clicking on a product displaying thir more images and allow to specify qty rquired (for Shoppng cart) How can dislay prevous and next record of the product ( i believe i ned to remember query defied for previous page but i ma not clear how to display current record and previous record and next record ... I want to display previous and next based on query reun SQL is made up below, but I have something similar sorted by dates, and NOT by ID. Currently I get this done by getting all the ID's in an array ordered by date and gleaning the two record ID's from that array. if the table is huge, that might not be the best way. Just seems like there should be an easier way to do it. Any ideas? Select startrek.ID, optc.opt_value as trk_series_id, optc.ID as trk_series_idID, startrek.trk_title, startrek.trk_episode, startrek.trk_season, startrek.trk_airdate, startrek.trk_stardate FROM startrek JOIN opt optc ON optc.ID = startrek.trk_series_id ORDER BY trk_airdate ASC
Hi all, Anyone give me a few hints how I can add a next and previous button to my pagination links? I currently have this: <?php } if($total_records > 5) ?> <div id="pg"> <?php { for ($i = 1; $i <= $total_pages; $i++) { echo "<a title='page $i' class='current' href='?catid=" . $catid ."&"; if($subid > 0) { echo "subid="; echo $subid . "&"; } echo "p= $i'>$i</a>"; } } ?> </div> Which displays them nicely, but I would like a next and previous button. Cheers
I want to list the previous (minus) 10 records. echo $rs['tree'];
} Thanks... I am trying to create a gallery page, one photo on the page with Next/Previous links either above or below but am having a little local difficulty. This is what I have:- Code: [Select] //>>> Set up arrays and variables <<< $piccies = array(); $exif = array(); $exifdata = array(); $pic = 0; $img =''; $date = ''; $time = ''; $caption = ''; $copyright =''; $imageid = 1; $first = 1; $last = 5; $self = $_SERVER['PHP_SELF'] . "?imageid="; //>>> Read images from folder and assign to the array $piccies[] <<< $piccies = read_folder(); //>>> Find image and extract the Exif info <<< $exif = read_exif_info($piccies, $pic); //>> Populate with required info from $exifdata with required info from $exif $exifdata = populate_exif_data($exif, $date, $time); $img = substr_replace($img, "", 0, 2); ?> <div id="pict"> <img src="<?php echo $img; ?>" /> <?php echo "<p>" . $caption . "</p>"; if ($imageid < $last) { echo "<a href=" . $self . ($imageid + 1) . "><h2>Next</h2></a>"; } if ($imageid > $first) { echo "<a href=" . $self . ($imageid - 1) . "><h2>Previous</h2></a>"; } ?> </div> It puts the 'Next' link in fine, but when clicked the link goes to the Parent directory:- Index of /php/gallery [ICO] Name Last modified Size Description [DIR] Parent Directory - [ ] functions.php 27-Oct-2011 09:25 2.1K [ ] gallery index.php 27-Oct-2011 09:45 1.8K [DIR] images/ 26-Oct-2011 16:00 - and when I look at the source I see that the link has not been constructed as I expected. This is the source:- Code: [Select] <div id="pict"> <img src="images/blue sky.jpg" /> <p>Blue Sky over Auld Reekie</p><a href=/php/gallery test.php?imageid=2><h2>Next</h2></a></div> where '/php/gallery test.php' is showing I expected 'images/filename.jpg' etc. and I just can't figureout what I have done wrong... I've got a page that displays all my blog entries on a single page. When you click on a specific entry, it pulls the post ID and loads the page specifically. From there, I wanted to have the option to click either onto the next or previous post by finding the next or previous ID in the database.. however, I know that sometimes posts are deleted, etc. so the ID's won't exactly be in order. What direction should I take with this? Hi guyz, I have created an event calender with PHP for customer appointments (calender.php). It is very basic and simple were all the days in the month are clickable; click on the day and you are redirected to diary page (diary.php) to view the appointments for that day. At the moment after the user is done looking at appointment and want to view another, they have to go back to the calender.php page for the next/previous day. I would like a previous and next button (Like the calender on MS Outlook) on the (diary.php page) so I don't have to keep going back to the calender.php page to go to the next or previous day. Please guys help me out, I realise it is quite complicated so any suggestions, ideas, or even if you have a similar script to see how you did it would be much appreciated and very helpful. Thanks guys! I'm not sure if this is a pure mySQL question or if it's more PHP but I thought this seemed like a good place to ask it.
I have a table which has data stored into it twice daily. The data stored is the timestamp, an account_ID, and the number of followers.
I am trying to add another field of "gains_losses". This should look at the previous entry for that account_ID, find out the followers data, and then find out the difference between the data being submitted today.
How would you go about doing this? I'm a bit stuck because I can't do it based on the date previously, and the times can change so I can't do a search for "Where time = this minus one day".
Here's a screenie of the table, you can see the account_ID repeats often as these are entries for each of these accounts.
I'm trying to figure out how to filter the results of a database query. For example somebody uses a php/javascript form to search for ford cars. When they see 100 results, they then narrow the results by model and/or color. Am I right in thinking that the way to do this is by creating a temporary table of the results? What is the best approach to what I'm trying to do? I messed around with a simple pagination script I found online. I'm still diving in and breaking it down to try and understand it better but I also was planning to have a "next" and "previous" link instead of just echoing out page numbers. I know I'll have to come up with some $pg+1 or $pg-1 function but how do I find out what $pg is currently on? function showSubmissions(){ $max = 9; // number of news entries per page $pg = $_GET['pg']; if(empty($pg)) { $pg = 1; } $limits = ($pg - 1) * $max; //view all the news articles in rows $q = mysql_query("SELECT * FROM submissions WHERE approved='YES' ORDER BY postdate DESC LIMIT " . $limits . ", $max") or die(mysql_error()); //the total rows in the table $totalres = mysql_result(mysql_query("SELECT COUNT(id) AS tot FROM submissions"), 0); //the total number of pages (calculated result), math stuff... $totalpages = ceil($totalres / $max); // BEGIN PAGINATION print ' <div class="paginationList"> <ul class="pgList"> <li><img src="images/icon_prevresult.png" title="" alt="" /></li>'; for($i = 1; $i <= $totalpages; $i++) { //this is the pagination link print '<li><a href="submissions.php?pg=' . $i . '">' . $i . ' </a></li>'; } print ' <li><img src="images/icon_nextresult.png" title="" alt="" /></li> </ul> </div>'; // END PAGINATION // PRINT RESULTS while($row = mysql_fetch_array($q)) { $id = $row['id']; $name = stripslashes($row['name']); $email = $row['email']; print ' <div class="sub-thumb-wrapper"> <div class="sub-thumb-user"> <div class="ps-name"><p class="sub-label">NAME:</p><a href="mailto:' . $email . '">' . $name . '</a></div> </div> </div>' . "\n"; } // END PRINT RESULTS } |