Jump to content

asmith6

Members
  • Posts

    26
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

asmith6's Achievements

Member

Member (2/5)

0

Reputation

  1. The OR statement only displays the first listed. In other words, if it's folder='blogs' or folder='politics', it'll display blogs only. And it's being displayed like an image image gallery. If you want to see how the image gallery works, you can find it here (the first post): http://www.phpfreaks.com/forums/index.php?topic=330918.0
  2. Good tips, good tips, and um, for some reason, the OR operator works, while the AND doesn't. Am I missing anything? This works, and always displays 'blog', and not display politics $pic2 = "SELECT * FROM images WHERE folder = 'blog' OR folder = 'politics'"; However, this does not work at all. $pic2 = "SELECT * FROM images WHERE folder = 'blog' AND folder = 'politics'"; Why is that?
  3. Wow, very nice lol. The problem was there was no spacing between the 'blog' and ORDER Thank you for the tip ^^;;
  4. If you mean echoing it at $pic2, like this: $pic2 .="WHERE folder = 'blog' ORDER by thumbnailID DESC LIMIT $Page_Start , $Per_Page" ; or like this: $pic2 .="ORDER by thumbnailID DESC LIMIT $Page_Start , $Per_Page WHERE folder = 'blog'" ; I already tried both and none worked. When I enter into phpmyadmin, SELECT * FROM images WHERE folder = 'blog', it works, but when I enter in SELECT * FROM images WHERE folder = 'blog' ORDER by thumbnailID DESC LIMIT, it doesn't.
  5. <?php $objConnect = mysql_connect("localhost","","cgdfgdfg") or die(mysql_error()); $objDB = mysql_select_db("ffdfvbbd"); $pic2 = "SELECT * FROM images"; if (!isset($_GET['Page'])) $_GET['Page']='0'; $pic1 = mysql_query($pic2); $Num_Rows = mysql_num_rows($pic1); $Per_Page = 16; // Per Page $Page = $_GET["Page"]; if(!$_GET["Page"]) {$Page=1;} $Prev_Page = $Page-1; $Next_Page = $Page+1; $Page_Start = (($Per_Page*$Page)-$Per_Page); if($Num_Rows<=$Per_Page) {$Num_Pages =1;} else if(($Num_Rows % $Per_Page)==0) {$Num_Pages =($Num_Rows/$Per_Page) ;} else {$Num_Pages =($Num_Rows/$Per_Page)+1; $Num_Pages = (int)$Num_Pages;} $pic2 .="ORDER by thumbnailID DESC LIMIT $Page_Start , $Per_Page" ; $pic1 = mysql_query($pic2); $cell = 0; $link1 = "SELECT * FROM images"; echo ' <div id="tablediv"> <table border="0" cellpadding="17" cellspacing="0" class="table"> <tr>'; while($pic = mysql_fetch_array($pic1)) { if($cell % 4 == 0) { echo '</tr><tr>'; } if($cell == 2) { echo ' <td> filler </td>'; } elseif ($cell == 3) { echo ' <td> filler </td>'; } else { echo ' <td> <a href="/' . $pic["link"] . '.php"> <div class="image"> <img src="https://s3.amazonaws.com/images/' . $pic["pic"] . '.png" alt="' . $pic["alt"] . '" height="200" width="200" /> </div> </a> </td>'; } $cell++; } echo '</tr></table></div>'; ?> The code above works just fine. However, once I add a WHERE function,as shown below, I get a "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource" error. <?php $objConnect = mysql_connect("localhost","","cgdfgdfg") or die(mysql_error()); $objDB = mysql_select_db("ffdfvbbd"); $pic2 = "SELECT * FROM images WHERE folder = 'blog' "; //WHERE FUNCTION IS HERE if (!isset($_GET['Page'])) $_GET['Page']='0'; $pic1 = mysql_query($pic2); $Num_Rows = mysql_num_rows($pic1); $Per_Page = 16; // Per Page $Page = $_GET["Page"]; if(!$_GET["Page"]) {$Page=1;} $Prev_Page = $Page-1; $Next_Page = $Page+1; $Page_Start = (($Per_Page*$Page)-$Per_Page); if($Num_Rows<=$Per_Page) {$Num_Pages =1;} else if(($Num_Rows % $Per_Page)==0) {$Num_Pages =($Num_Rows/$Per_Page) ;} else {$Num_Pages =($Num_Rows/$Per_Page)+1; $Num_Pages = (int)$Num_Pages;} $pic2 .="ORDER by thumbnailID DESC LIMIT $Page_Start , $Per_Page" ; $pic1 = mysql_query($pic2); My mysql table includes column thumbnailID folder link pic alt time The folder column is there so I can specify what I want in the page. Anyhow, why won't it work?
  6. Thanks man, can't believe I didn't notice the ASC before.
  7. I'm tired and just about given up. Can anybody help me? <?php $objConnect = mysql_connect("localhost","","root") or die(mysql_error()); $objDB = mysql_select_db("sdf"); $pic2 = "SELECT * FROM images"; if (!isset($_GET['Page'])) $_GET['Page']='0'; $pic1 = mysql_query($pic2); $Num_Rows = mysql_num_rows($pic1); $Per_Page = 16; // Per Page $Page = $_GET["Page"]; if(!$_GET["Page"]) {$Page=1;} $Prev_Page = $Page-1; $Next_Page = $Page+1; $Page_Start = (($Per_Page*$Page)-$Per_Page); if($Num_Rows<=$Per_Page) {$Num_Pages =1;} else if(($Num_Rows % $Per_Page)==0) {$Num_Pages =($Num_Rows/$Per_Page) ;} else {$Num_Pages =($Num_Rows/$Per_Page)+1; $Num_Pages = (int)$Num_Pages;} $pic2 .=" order by thumbnailID ASC LIMIT $Page_Start , $Per_Page"; $pic1 = mysql_query($pic2); $cell = 0; $link1 = "SELECT * FROM images"; $result_link1 = mysql_query($link1); $link = mysql_fetch_array($result_link1); $alt1 = "SELECT * FROM images"; $alt = mysql_fetch_array(mysql_query($alt1)); echo ' <div id="tablediv"> <table border="0" cellpadding="17" cellspacing="0" class="table"> <tr>'; while($pic = mysql_fetch_array($pic1)) { if($cell % 4 == 0) { echo '</tr><tr>'; } if($cell == 2) { echo ' <td> fillerspace </td>'; } elseif ($cell == 3) { echo ' <td> Fillerspace2 </td>'; } else { echo ' <td> <a href="/' . $link["link"] . '.php"> <div class="image"> <img src="https://s3.amazonaws.com/image/' . $pic["pic"] . '.png" alt="' . $alt["alt"] . '" height="200" width="200" /> </div> </a> </td>'; } $cell++; } echo '</tr></table></div>'; ?> Basically, there are a couple of faults with this code. I didn't include the pagination part, but there is, for simplicity. But right now, when I insert a new record such as this: INSERT INTO `images` VALUES (' ', 'blog', 'yo', '6', 'hello', '2011-02-15T07:24:17Z') The columns go in order of thumbnailID, folder, link, pic, alt, and time.^^^^^^^^ several problem arises. One, the new record is not displayed as the newest entry on my site. So the record is actually placed in one of the paginated pages. How can I reverse the order? The other thing is, it seems like my pic column is the only thing being understood. You see, when I inserted the above record, I checked my site and saw the pic 6, but the link wasn't 'yo', and the alt wasn't 'hello'. Why is that? By the way, my host is awfully terrible. Maybe it's just having a major delay in reading the link and alt? I don't know. That would be the only reasonable answer, unless my code is off. Thank you, and I'll check 10hours from now.
  8. I've tried multiple mysql tutorials thus far and some of them, have codes like this: $Page = $_GET["BLAH"]; if(!$_GET["BLAH"]) , I get an error of "Notice: Undefined Index: BLAH" in the file location and line number. Does anybody know what undefined index means and how I can patch up the problem? Thanks!
  9. This is my current code (actually it's heavily based off of a code a fellow phpfreak made. Basically, this makes it easy to put up images. When I want to put up a linkable image, I simply need to add to the image_links my subfolder, and add to the image_description my description. Anyways, here it is, you can try and run it yourself: <?php $rows_per_page = 2; $cols_per_page = 2; $image_href = '<a href=/'; $image_links = array('otherstuff/nature>', 'otherstuff/volcanoes>', 'otherstuff/papersupplies>''); $img_srcs = '<img src="https://s3.amazonaws.com/imgs/'; $images = array(); for($i = 1; $i < 10; $i++) { $images[$i] = $i; } $image_ending = '.png" height="200" width="200" /></a>'; $image_break = '<br /><div class="timeago"><div id="submitted">submitted </div>'; $image_descriptions = array('<abbr class="timeago" title="2011-03-13T07:24:17Z"></abbr></div>', '<abbr class="timeago" title="2011-03-13T07:24:17Z"></abbr></div>', '<abbr class="timeago" title="2011-03-13T07:24:17Z"></abbr></div>'); $total_images = count($images); $images_per_page = $rows_per_page * $cols_per_page; $total_images = count($images); $total_pages = ceil($total_images / $images_per_page); $current_page = (int) $_GET['page']; if($current_page<1 || $current_page>$total_pages) { $current_page = 1; } //Get records for the current page $page_image_links = array_splice($image_links, ($current_page-1)*$images_per_page, $images_per_page); $page_images = array_splice($images, ($current_page-1)*$images_per_page, $images_per_page); $page_image_descriptions = array_splice($image_descriptions, ($current_page-1)*$images_per_page, $images_per_page); $slots = "<table border=\"0\">"; for($row=0; $row<$rows_per_page; $row++) { $slots .= "<tr>"; for($col=0; $col<$cols_per_page; $col++) { $imgIdx = ($row * $rows_per_page) + $col; $img = (isset($page_images[$imgIdx])) ? "{$image_href}{$page_image_links[$imgIdx]}{$img_srcs}{$page_images[$imgIdx]}{$image_ending}{$image_break}{$page_image_descriptions[$imgIdx]}" : ' '; $slots .= "<td class='tables'>$img</td>"; } $slots .= "</tr>"; } $slots .= "</table>"; //Create pagination links $first = "First"; $prev = "Prev"; $next = "Next"; $last = "Last"; if($current_page>1) { $prevPage = $current_page - 1; $first = "<a href=\"w4rmoemfdoiemroifmeromfxdnxvl.php?page=1\">First</a>"; $prev = "<a href=\"w4rmoemfdoiemroifmeromfxdnxvl.php?page={$prevPage}\">Prev</a>"; } if($current_page<$total_pages) { $nextPage = $current_page + 1; $next = "<a href=\"w4rmoemfdoiemroifmeromfxdnxvl.php?page={$nextPage}\">Next</a>"; $last = "<a href=\"w4rmoemfdoiemroifmeromfxdnxvl.php?page={$total_pages}\">Last</a>"; } ?> <html> <title></title> <head><style type="text/css"> #submitted {color: #888888; font-family:Verdana, Geneva, sans-serif; font-size: .8em; float:left;} .tables {padding-left: 20px; padding-right: 20px;} .timeago {color: #888888; font-family:Verdana, Geneva, sans-serif; font-size: .8em; float:right;} </style><script src="/static/jquery-1.5.1.js" type="text/javascript"></script> <script src="/static/jquery.timeago.js" type="text/javascript"></script> <script type="text/javascript"> jQuery(document).ready(function() { jQuery("abbr.timeago").timeago(); });</script></head> <body> <h2>Here are the records for page <?php echo $current_page; ?></h2> <ul> <?php echo $slots; ?> </ul> Page <?php echo $current_page; ?> of <?php echo $total_pages; ?> <br /> <?php echo "view more: {$next}"; ?> </body> </html> --------------------------------------------------------------------- Now, I want to prepare for the long run. If I ever get up to say 1000 images, it's gonna take a while to parse 1000 image_links and 1000 image_descriptions, so instead, I want it to be read off of a database instead. I know low-level mySQL, I can usually understand the syntax. My problem is, I can never wrap my head around the logic. You can lock me in a week for a week and I still wouldn't be able to figure it out. But show me the code, and I'd say "I get it!" Can anyone please help me out, rather by giving a rough code or good thorough advice to carry it out? I'd prefer a good rough code but I'll take anything at this point :[ Thanks! MOD EDIT: . . . tags added.
  10. <?php $image_url = 'images/'; //User defined variables for page settings $rows_per_page = 2; $cols_per_page = 4; //Master array of ALL the images in the order to be displayed $images = array( 'image1.jpg', 'image2.jpg', 'image3.jpg', 'image4.jpg', 'image5.jpg', 'image6.jpg', 'image7.jpg', 'image8.jpg', 'image9.jpg', 'image10.jpg', 'image11.jpg', 'image12.jpg', 'image13.jpg', 'image14.jpg', 'image15.jpg', 'image16.jpg', 'image17.jpg', 'image18.jpg', 'image19.jpg' ); //END USER DEFINED VARIABLES //System defined variable $records_per_page = $rows_per_page * $cols_per_page; $total_records = count($images); $total_pages = ceil($total_records / $records_per_page); //Get/define current page $current_page = (int) $_GET['page']; if($current_page<1 || $current_page>$total_pages) { $current_page = 1; } //Get records for the current page $page_images = array_splice($images, ($current_page-1)*$records_per_page, $records_per_page); //Create ouput for the records of the current page $ouput = "<table border=\"1\">\n"; for($row=0; $row<$rows_per_page; $row++) { $ouput .= "<tr>\n"; for($col=0; $col<$cols_per_page; $col++) { $imgIdx = ($row * $rows_per_page) + $col; $img = (isset($page_images[$imgIdx])) ? "<img src=\"{$image_url}{$page_images[$imgIdx]}\" />" : ' '; $ouput .= "<td>$img</td>\n"; } $ouput .= "</tr>\n"; } $ouput .= "</table>"; //Create pagination links $first = "First"; $prev = "Prev"; $next = "Next"; $last = "Last"; if($current_page>1) { $prevPage = $current_page - 1; $first = "<a href=\"test.php?page=1\">First</a>"; $prev = "<a href=\"test.php?page={$prevPage}\">Prev</a>"; } if($current_page<$total_pages) { $nextPage = $current_page + 1; $next = "<a href=\"test.php?page={$nextPage}\">Next</a>"; $last = "<a href=\"test.php?page={$total_pages}\">Last</a>"; } ?> <html> <body> <h2>Here are the records for page <?php echo $current_page; ?></h2> <ul> <?php echo $ouput; ?> </ul> Page <?php echo $current_page; ?> of <?php echo $total_pages; ?> <br /> <?php echo "{$first} | {$prev} | {$next} | {$last}"; ?> </body> </html> This current code provides an easy way of uploading pictures and having the other pictures move automatically without the need of a database. But I must wonder, if doing this on a database would be faster. Would it be? I mean the example adobe shows I'm only using 19 pictures, but if I ever reach say 1000 pictures, would the php file be too big? Should I just make a database now or it doesn't matter? Also, the code above, which I took from a phpfreak member, has the pagination not working. Anyone care to do a diagnosis? Thanks!
  11. Figured it out, in case anyone was wondering.
  12. This is probably the worst question ever uttered onto this forum, but I have really no javascript nor jquery experience. I just want to use this code on my site, and be on my way. The code is timeago and can be found here: http://timeago.yarp.com/ The steps to use the timeago plugin seems really simple. Unfortunately, I am a pretty simple man, and do not know how to use it. Can someone babywalk me through this? I just go to the second part (domready) before I was in utter confusion, with google not helping. Please, all feedback will be useful. Thanks!
  13. My familiarity with php is moderately-little (I can understand medium difficulty code, but can only code the simplest php stuff), but my familiarity with javascript is pretty much none. So what you suggest is insert this at the bottom of my html page: <script type="text/javascript"> var d = new Date() var gmtHoursOffset = -d.getTimezoneOffset()/60; </script> That's it right? And for php, I would still use the date_default_timezone_set, as you suggested earlier, correct?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.