Jump to content

QuickOldCar

Staff Alumni
  • Posts

    2,972
  • Joined

  • Last visited

  • Days Won

    28

Everything posted by QuickOldCar

  1. That is asking a lot, try to post one question at a time and relevant code along with it to get better assistance. First off you should not display so many images on a single page. You should use a database to store image locations,titles,description or any other data. You should break down each section of the images into categories versus all the same page. Each category being it's own page, or the category is displayed with a single php file using a query for the category. Use navigation links or a dropdown in a form to pick a category. On this page try to paginate the displayed images. http://www.phpfreaks.com/tutorial/basic-pagination You could just include seperate php files with if/else statments if only have a few categories. Now we get to the single display of the images. create a php page tailored to the single image Use $_GET to get the image id from the multi-display page $id = $_GET['id'];//sanitize this http://www.tizag.com/phpT/postget.php http://www.w3schools.com/php/php_get.asp So where you have your page with all the images and id's, upon clicking make the target href link go to the single page for images Get familiar with doing a mysql select query http://php.net/manual/en/function.mysql-query.php http://www.tizag.com/mysqlTutorial/mysqlselect.php Just showing an example how to link to the single page $id = $row['id']; $image_location = $row['image_location']; echo "<a href='http://www.jacobshultz.com.au/test/view.php?id=$id'><img src='$image_location' border='0'></a>"; Let's stop there for now until get something going, feel free to ask more.
  2. http://www.phpfreaks.com/tutorial/basic-pagination
  3. $items['title']['value'] = "<a href='".$items['title']['value']."'>Download Document</a>"; echo $items['title']['value'];
  4. <form method="post" action=""> <select name="criteria"> <option value="selectCriteria">Select Criteria</option> <option value="GPA">GPA</option> <option value="Diploma">Diploma</option> <option value="Gender">Gender</option> <option value="LearningAttitudes">Learning Attitudes</option> </select> <input type="submit" /> </form><br><br> <?php $criteria = $_POST['criteria']; echo $criteria; ?>
  5. I think you are in the html frame of mind. Here is a simple demo with dummy data representing database results. http://get.blogdns.com/dynaindex/post-variable.php The code for it is below it, it displays the results of a single post within the same page. php is dynamic, you create the php pages, then the content can be dynamic or set to what you desire. You should keep your about page static. The dynamic content is usually mysql select queries from a database Lets say you are displaying posts that are split onto a page, like 20 results per page, thats called pagination. http://www.phpfreaks.com/tutorial/basic-pagination It would have urls like site.com?page=1 site.com?page=2 site.com?page=3 and so on now for each post on a single page it would have an id number, or at least you should. so now we can do a "View More" link to display additional information and send them a single page for one id. lets make a hyperlink for each post id leading them to view.php <a href="view.php?id=<?php echo $id;?>">View More</a> or in a php echo echo "<a href='view.php?id=$id'>View More</a>"; view.php contents: connect to database $id = $_GET['id'];//could also not be a number but a unique value sanitize the GET,if this is a number check with is_numeric(), otherwise use mysql_real_escape_string() mysql select query echo the results
  6. It's called GET, can be used in a form or typed directly into the browser with no form, even from a hyperlink you create. http://php.net/manual/en/reserved.variables.get.php http://www.w3schools.com/php/php_get.asp http://www.tizag.com/phpT/postget.php
  7. Use the nl2br function http://php.net/manual/en/function.nl2br.php
  8. <?php define('BASE_PATH', 1); include('init.php'); $template->set('page', 'gallery'); $template->add('css', array('path' => 'styles/slimbox2.css')); $template->add('js', array('path' => 'scripts/slimbox2.js')); $template->place('header'); error_reporting(E_ALL ^ E_NOTICE); //$cat_thumb_width = 310; $cat_thumb_height = 140; //$thumb_width = 140; $thumb_height = 140; function scan_dir($dir,$regex = "/.jpg|.png|.gif/") { $objects = array_diff(scandir($dir), array('.', '..')); $object_array = array(); foreach ($objects as $object) { if (is_dir("$dir/$object")) { $i++; $object_array[$i]['title'] = $object; $object_array[$i]['images'] = scan_dir("$dir/$object"); } else if (preg_match($regex, $object)) { $i++; $object_array[$i] = $object; } } return $object_array; } if(!function_exists('scandir')) { function scandir($directory, $sorting_order = 0) { $dh = opendir($directory); while (($file = readdir($dh)) !== false) { $files[] = $file; } if($sorting_order == 0) { sort($files); } else { rsort($files); } return $files; } } function make_url($object) { return "gallery.php?c=$object"; } function escape_url($url) { $url = str_replace('%20', '+', $url); return str_replace('%2F', '/', urlencode($url)); } function get_request($property, $default = null) { if (isset($_REQUEST[$property])) { return $_REQUEST[$property]; } else { return $default; } } $c = get_request('c', 0); $dir = 'media/'; $dir_tree = scan_dir($dir); $dir_count = count($dir_tree); $img_count = count($dir_tree[$c]['images']); if ($c > $dir_count) { $c = 0; } ?> <h2>Gallery</h2> <ul id="gallery-categories"> <?php foreach ($dir_tree as $gallery) { if ($dir_tree[$c]['title'] === $gallery['title']) { echo '<li class="active">'; } else { echo '<li>'; } echo '<a href="' . make_url(++$i) . '">'; if ($c < 1) { if ($dh = opendir($dir . $gallery['title'])) { while (($image = readdir($dh)) !== FALSE) { if (preg_match("/.jpg|.png|.gif/", $image)) { echo '<img src="resize.php?src=/' . escape_url($dir . $gallery['title'] . '/' . $image) . "&h=$cat_thumb_height" . '"><br>'; break; } } } } echo $gallery['title']; echo '</a></li>'; } ?> </ul> <?php if ($img_count > 0) { ?> <ul id="gallery-images"> <?php foreach ($dir_tree[$c]['images'] as $image) { echo '<li><a href="' . $dir . $dir_tree[$c]['title'] . '/' . $image . '" title="' . str_replace('_', ' ', substr($image, 0, strlen($image) - 4)) . '" rel="lightbox-group">'; echo '<img src="' . 'resize.php?src=/' . escape_url($dir . $dir_tree[$c]['title'] . '/' . $image) . "&h=$thumb_height" . '">'; echo '</a></li>'; } ?> </ul> <?php } ?> <?php $template->place('footer'); ?>
  9. $testArray = range(1,20); That is a range, it saved me from doing this....(but now I see I'm doing it anyway) same as $testArray = array("1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20"); foreach will loop each value within the array http://php.net/manual/en/control-structures.foreach.php Arrays start at key position zero $value[0] All i did is replace the first key value with something else
  10. the ../images was a alocation for me to test the function function scan_dir($dir,$regex = "/.jpg|.png|.gif/" { $objects = array_diff(scandir($dir), array('.', '..')); $object_array = array(); foreach ($objects as $object) { if (is_dir("$dir/$object")) { $i++; $object_array[$i]['title'] = $object; $object_array[$i]['images'] = scan_dir("$dir/$object"); } else if (preg_match($regex, $object)) { $i++; $object_array[$i] = $object; } } return $object_array; }
  11. I didn't see the reason to have the regex in the input <?php function scan_dir($dir) { $regex = "/.jpg|.png|.gif/"; $objects = array_diff(scandir($dir), array('.', '..')); $object_array = array(); foreach ($objects as $object) { if (is_dir("$dir/$object")) { $i++; $object_array[$i]['title'] = $object; $object_array[$i]['images'] = scan_dir("$dir/$object"); } else if (preg_match($regex, $object)) { $i++; $object_array[$i] = $object; } } return $object_array; } $images = scan_dir("../images"); foreach ($images as $image){ echo $image."<br />"; } ?>
  12. <?php header("refresh:5;url=http://localhost/php/upload.php"); echo "<br>File $fileName uploaded<br>"; ?>
  13. Do you mean something like this? <?php $testArray = range(1,20); $testArray[0] = "<a href='$testArray[0]'>$testArray[0]</a>"; foreach($testArray as $value){ echo $value."<br />";; } ?>
  14. $str = preg_replace('/\s\s+/', ' ', $str);//trims space $str = str_replace(array(' ',' ',' '), ' ', $str);//converts 2,3 and 4 spaces to one
  15. Do your comments in a database. You link comments to post id's. Here's something to get you in the right direction. http://www.zimmertech.com/tutorials/php/25/comment-form-script-tutorial.php
  16. You need to wrap in php tags and also echo the variable as one example from this: <img border="0" src="$s_photo_path" width="284" height="144"> to this: <img border="0" src="<?php echo $s_photo_path;?>" width="284" height="144">
  17. http://www8.hp.com/us/en/support-drivers.html
  18. Although I feel this is an ok registration system if wanted to add custom items to it, but still lacking many features. You could try this one perhaps using jquery http://tutorialzine.com/2009/10/cool-login-system-php-jquery/
  19. CREATE TABLE IF NOT EXISTS `dbusers` ( `id` int(11) NOT NULL auto_increment, `username` varchar(32) collate utf8_unicode_ci default NULL, `password` char(32) collate utf8_unicode_ci default NULL, `email` varchar(32) collate utf8_unicode_ci default NULL, PRIMARY KEY (`id`), UNIQUE KEY `username` (`username`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  20. As a note..if you want the login to be on another page..you can just make a form that leads to the login page. Now as for your problem. Are you using all of these exact files in this post? http://www.phpfreaks.com/forums/index.php?topic=338735.msg1596372#msg1596372 the others were different Did you drop the table and create a new one with these values? CREATE TABLE dbUsers ( id int NOT NULL AUTO_INCREMENT, username varchar(32) Unique, password char(32), email varchar(32), PRIMARY KEY (id) ) I assure you everything works as expected, besides better error messages on a few items.
  21. your ads outputs data, so must not be first, in register and also login there are header redirects you are also including both login and register in the same form place href links to them instead, thats the way it's set up and to do redirections <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Fledge Press - Login</title> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <link rel="stylesheet" type="text/css" href="/fledge_styles.css"> <style type="text/css"> </style> </head> <body> <?php include("nav_ads.php"); ?> <div id="main"> <h4><a href="login.php">Login</a></h4> <h4>Or <a href="register.php">Register</a> a new account:</h4> <h4>Why register?</h4> <p>Registry is required in order for you to access downloadable content. It doesn't cost you anything - unless you want to become a supporter!</p> </div> <?php include("bottom.php"); ?> </body>
  22. show the users.php file you made, you can't output anything before a header redirect. as for the duplicate entry, that username is already registered in the database
×
×
  • 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.