PHP - Php Pagination Display Images In A Table Help
Ok the pagination part is all working fine.
but i thought id be able to create a heap variables inside the loop then display the images in a table. the only trouble is all variables are grabbing the same img. i need them to grab the 10 different records. thanks Code: [Select] $sql = "SELECT * FROM mongrels_db.gallery ORDER BY id DESC LIMIT $offset, $rowsperpage "; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); // while there are rows to be fetched... while ($list = mysql_fetch_array($result)) { $img1=$list['img']; $img2=$list['img']; $img3=$list['img']; $img4=$list['img']; $img5=$list['img']; $img6=$list['img']; $img7=$list['img']; $img8=$list['img']; $img9=$list['img']; $img10=$list['img']; // echo data } // end while echo "<table><tr>"; echo "<td>"."<img src='../gallery/".$img1 ."' width='100' height='100''> "."</td>"; echo "<td>"."<img src='../gallery/".$img2 ."' width='100' height='100''> "."</td>"; echo "<td>"."<img src='../gallery/".$img3 ."' width='100' height='100''> "."</td>"; echo "<td>"."<img src='../gallery/".$img4 ."' width='100' height='100''> "."</td></tr>"; echo "<tr><td>"."<img src='../gallery/".$img5 ."' width='100' height='100''> "."</td>"; echo "<td>"."<img src='../gallery/".$img6 ."' width='100' height='100''> "."</td>"; echo "<td>"."<img src='../gallery/".$img7 ."' width='100' height='100''> "."</td>"; echo "<td>"."<img src='../gallery/".$img8 ."' width='100' height='100''> "."</td>"; echo "<tr><td>"."<img src='../gallery/".$img9 ."' width='100' height='100''> "."</td>"; echo "<td>"."<img src='../gallery/".$img10 ."' width='100' height='100''> "."</td></tr>"; Similar TutorialsImage name will come from database. It can be displayed in divs or table cells. Which is better using divs or table cells? Can anyone post sample code? http://img28.imageshack.us/i/44233003.png/ Hi, here's my problem: I am trying to make a simple online buying website and I want to display a table with all the fields for each item. So I got that part down which is to just use mysql_fetch_assoc("SELECT * FROM myTable") and use the html table tags stuff, but now I want to display my images in the table, so here's my code to display my mysql database table in html's table tag along w/ php: <html> <head> <title>My Online buying website project</title> </head> <body> <?php mysql_connect("localhost","root"); mysql_select_db("myTable"); $imagesArray=array("Apple_iPhone3GS.jpg","Apple_iPhone4.jpg","product3.jpg","product4.jpg","product5.jpg"); $result=mysql_query("SELECT Name, Manufacturer, Price, Description, SimSupport FROM myTable"); if(mysql_num_rows($result))//if there is at least one entry in bellProducts, make a table { print "<table border='border'>"; print "<tr> <th>Name</th> <th>Manufacturer</th> <th>Price</th> <th>Description</th> <th>SimSupport</th> </tr>"; //NB: now output each row of records while($row=mysql_fetch_assoc($result)) { extract($row); print "<tr> <td>$Name</td> <td>$Manufacturer</td> <td>$Price</td> <td>$Description</td><td>$SimSupport</td> </tr>"; }//END WHILE }//END IF ?> </table> </body> </html> *So how do I go about adding my images in this table? heres my code: Code: [Select] <?php if ($pagi_count > 1) { echo '<ul class="pagination">'; echo '<li><a href="#">«</a></li>'; $pagi_start = 1; $pagi_end = $pagi_count; for ($p = $pagi_start; $p <= $pagi_end; $p++) { $link = "$url/page/".$get_letter; if ($p > 1) $link .= "/$p"; if ($p == $pagi_num) $class = ' class="current"'; else $class = ''; echo '<li'.$class.'><a href="'.$link.'">'.$p.'</a></li>'; } echo '<li><a href="#">»</a></li>'; echo '</ul>'; } ?> now this works fine, however i want it to only show 20 page numbers, and if there are more than 20 total pages, i want the current page to be in the middle of the list (unless of course the current page is 1 or 2 then it would be more to the left of the list........ example: with 13 total pages, on page 8: << 1 2 3 4 5 6 7 ( 9 10 11 12 13 >> with 55 total pages, on page 2: << 1 (2) 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 >> with 65 total pages, on page 12: << 2 3 4 5 6 7 8 9 10 11 (12) 13 14 15 16 17 18 19 20 21 >> im really stumped on the math for this....any help would be much appreciated. Hello, I am creating a simple catalog feature on my website for logging collections in a list format. Using built in pagination (cakephp) on my list to sort by name, I lose my images after the sort. Any ideas how to get around this? Here is the code. View: Code: [Select] <td><div align='center'> <?php echo $this->Html->toggleBoolean($nintendo['Nintendo']['box']); ?> </div></td> Helper: Code: [Select] function toggleBoolean($value){ if ($value == 1) return "<img src='../img/fam/tick.png' alt='Yes' />"; else return "<img src='../img/fam/cross.png' alt='No' />"; } Regards, Ash Hi I'm trying to setup Pagination at the bottom of the page after showing 10 images in the following script but have no clue where to start and how to implement it into the script. This is my pagination with the number bar: Code: [Select] <?php $page = $_GET['page']; $category = $_GET['cat']; $your_db = @ new mysqli("$hostname","$username", "$password"); if (mysqli_connect_errno()) { echo 'ERROR!<br />'.mysqli_connect_errno() .' - Not connected : '.mysqli_connect_error().'<br />'; die; } else { $db_connect = $your_db->select_db("database"); if (!$db_connect) { echo 'Error!'; die; } } echo '<p>'; $query = "select distinct fldCategory from tablename order by fldCategory"; $result = $your_db->query($query); $number_of_records = $result->num_rows; for ($i = 0; $i < $number_of_records; $i++) { $row = $result->fetch_assoc(); echo '<a href="page_name.php?cat='.stripslashes($row['fldCategory']).'">'; echo stripslashes($row['fldCategory']); echo '</a> / '; } echo '</p>'; if ($category) { $query = "select fldID, fldTitle, fldCategory, fldIconMedium, fldLink from tablename where fldCategory = '$category' order by fldCategory"; } else { $query = "select fldID, fldTitle, fldCategory, fldIconMedium, fldLink from tablename order by fldCategory"; } $result = $your_db->query($query); $number_of_records = $result->num_rows; $num_pages = $number_of_records / 7; if (($number_of_records % 7) > 0 ) { $num_pages++; } if (strlen($page) == 0) { $page = 0; } else { $page = $page * 7; } echo '<table border="1">'; $row_num = 1; $result->data_seek($page); for ($i = $page; $i < $number_of_records; $i++) { if ($row_num <= 7) { echo '<tr>'; for ($col_num = 0; $col_num < 5; $col_num++) { $row = $result->fetch_assoc(); echo '<td>'; show_image(stripslashes($row['fldIconMedium']),stripslashes($row['fldTitle'])); echo '<br />'; echo '<a href="'.stripslashes($row['fldLink']).'" target="_blank">'; echo stripslashes($row['fldTitle']); echo '</a>'; echo '</td>'; } $row_num++; echo '</tr>'; } else { break; } } echo '</table>'; for ($j = 0; $j < $num_pages; $j++) { $page_link = $j + 1; echo '<a href="page_name.php?page='.$j.'&cat='.$category.'">'.$page_link.'</a> '; } echo ' '.$number_of_records; function show_image($image_name, $alt) { if (file_exists("path_to_images/$image_name")) { $dim_img = getimagesize('path_to_images/'.$image_name); echo '<img src="path_to_images/'.$image_name.'" alt = '.$alt.' border=0 align="bottom"'; echo 'width = '. $dim_img[0] .' height = ' .$dim_img[1] . ' />'; } else echo 'NO IMAGE'; } ?> To see it in action, here is the link to the 'skill games' section of the pagination script: http://netroxy.com/games2.php?cat=skills Ok here is the issue 1. As you can see, all the results displayed in the pagination script is correct, but what confuses me is the extra blank images that continue on in the table of the pagination table. I tried replacing the queries to see if the extra blank images would be removed like this: Code: [Select] $query = "select fldID, fldTitle, fldCategory, fldIconMedium, fldLink from tablename where fldCategory = '$category' and length(fldIconMedium) > 0 order by fldCategory"; } else { $query = "select fldID, fldTitle, fldCategory, fldIconMedium, fldLink where length(fldIconMedium) > 0 from tablename order by fldCategory"; So you see, I used 'length(fldIconMedium) > 0' making images less than 0 to see if the rest of the blank images would disappear from the cells in the table. This has not worked. Hence 'fldIconMedium' is the column for the images in the mysql database. Visit the link and you'll see the extra blank images through the results. This also applies when search for other game categories, blank images appear and I cant remove those extra blank images from the table. I have this script from http://lampload.com/...,view.download/ (I am not using a database) I can upload images fine, I can view files, but I want to delete them. When I press the delete button, nothing happens
http://www.jayg.co.u...oad_gallery.php
<form>
<?php $dir = dirname(__FILENAME__)."/images/gallery" ; $files1 = scandir($dir); foreach($files1 as $file){ if(strlen($file) >=3){ $foil = strstr($file, 'jpg'); // As of PHP 5.3.0 $foil = $file; $pos = strpos($file, 'css'); if ($foil==true){ echo '<input type="checkbox" name="filenames[]" value="'.$foil.'" />'; echo "<img width='130' height='38' src='images/gallery/$file' /><br/>"; // for live host //echo "<img width='130' height='38' src='/ABOOK/SORTING/gallery-dynamic/images/gallery/ $file' /><br/>"; } } }?> <input type="submit" name="mysubmit2" value="Delete"> </form>
any ideas please?
thanks
I am looking to display image paths in a row separated by commas. There are 6 images that goes to each user and I would like only the 6 images at be in each " " Like this: "images/listings/listing_516013019A-only.jpg,images/listings/listing_848813453A-1.jpg,images/listings/listing_664613453A-2.jpg,images/listings/listing_520313453A-3.jpg,images/listings/listing_690513453A-4.jpg,images/listings/listing_125113453A-5.jpg,images/listings/listing_641013453A-6.jpg," "images/listings/listing_736913186A-1.jpg,images/listings/listing_822713186A-2.jpg,images/listings/listing_136513186A-3.jpg,images/listings/listing_700313186A-4.jpg,images/listings/listing_716013186A-5.jpg,images/listings/listing_213113186A-6.jpg," "images/listings/listing_292113254A..-1.jpg,images/listings/listing_854413254A..-2.jpg,images/listings/listing_446013254A..-3.jpg,images/listings/listing_676313254A..-4.jpg,images/listings/listing_563413254A..-5.jpg,images/listings/listing_341513254A..-6.jpg," Right now it is displaying them like this "images/listings/listing_516013019A-only.jpg," "images/listings/listing_848813453A-1.jpg," "images/listings/listing_664613453A-2.jpg," "images/listings/listing_520313453A-3.jpg," "images/listings/listing_690513453A-4.jpg," "images/listings/listing_125113453A-5.jpg," "images/listings/listing_641013453A-6.jpg," "images/listings/listing_736913186A-1.jpg," "images/listings/listing_822713186A-2.jpg," "images/listings/listing_136513186A-3.jpg," "images/listings/listing_700313186A-4.jpg," "images/listings/listing_716013186A-5.jpg," "images/listings/listing_213113186A-6.jpg," "images/listings/listing_292113254A..-1.jpg," "images/listings/listing_854413254A..-2.jpg," "images/listings/listing_446013254A..-3.jpg," "images/listings/listing_676313254A..-4.jpg," "images/listings/listing_563413254A..-5.jpg," "images/listings/listing_341513254A..-6.jpg," Here is the code I have: Code: [Select] <?php // Make a MySQL Connection mysql_connect("localhost", "xxxxxxxx", "xxxxxxxx") or die(mysql_error()); mysql_select_db("xxxxxxxx") or die(mysql_error()); $result = mysql_query("SELECT * FROM listimages ORDER BY listimages.listingid DESC ") or die(mysql_error()); while($row = mysql_fetch_array($result)) { echo "\""; echo "$row[imagepath],"; echo "\""; echo "<br>"; } ?> My tables for the images is "listimages" and the columns a id (which are the auto_increments) imagepath (which shows the path/image1.jpg) mainimage (which just shows 0 or 1 depending on the picture that is the default for that listing, 1 being default) listingid (shows numbers 1 2 3 etc corresponding to the Id in the listings table to show what images go with what listing) There are up to 6 images for each listing. Any idea how to fix this? I'm creating a funeral home site and on the side of the page I would like to display the last 5 funeral obituaries that are in mySQL database (name and certain sized image (images are in "image" field) w/ a link to an "obituaries detail page for the individual deceased person"). I am able to do this successfully listing only the names....how can I list the image associated with the name? This is what I have so far: Code: [Select] <?php include("connect.php"); ?> Code: [Select] <?php $query = "SELECT id, deceased_name, deceased_date, DATE_FORMAT(deceased_date, '%M %D, %Y') as datetext"; $query .= " FROM scales_obits ORDER BY deceased_date DESC LIMIT 5"; $listings = mysql_query($query); if (!listings) { echo("<p>Error retrieving listings from lookup table<br>". "Error: " . mysql_error()); exit(); } echo("<table border=\"0\" width=\"100%\" class=\"obit\">"); while ($listing = mysql_fetch_array($listings)) { $deceased_name = $listing["deceased_name"]; $deceased_date = $listing["datetext"]; $id = $listing["id"]; echo("<tr><td width=\"100%\"><a href=\"obitdetail.php?id=".$id."\"><strong>".$deceased_name."</strong></a></td><td> </td>"); } echo("</table>"); ?> I read everywhere where it says not to stoe images in MYSQL but I have a code where I'm trying to display the images. They are all jpegs that are stored in the table. Here is the code Code: [Select] <?php include "dbaptsConfig.php"; include "searchaptsstyle.css"; // test id, you need to replace this with whatever id you want the result from $id = "1"; // what you want to ask the db $query = "SELECT * FROM `apartments` WHERE `id` = ".$id; // actually asking the db $res = mysql_query($query, $ms); // recieving the answer from the db (you can only use this line if there is always only one result, otherwise will give error) $result = mysql_fetch_assoc($res); // if you uncomment the next line it prints out the whole result as an array (prints out the image as weird characters) // print_r($result); // print out specific information (not the whole array) echo "<br/>"; echo "<div id='title'>".$result['title']."<br/></div>"; echo "<br/>"; echo "<div id='description'>".$result['description']."<br /></div>"; echo "<br/>"; echo "<div id='table'><tr>"; echo "<td bgcolor='#FFFFFF' style='color: #000' align='center'> Provider's Phone Number: ".$result['phone']."<br /></td>"; echo "<td bgcolor='#FFFFFF' style='color: #000' align='center'> Provider: ".$result['service']."<br /></td>"; echo "<td bgcolor='#FFFFFF' style='color: #000' align='center'> Borough: ".$result['county']."<br /></td>"; echo "<td bgcolor='#FFFFFF' style='color: #000' align='center'> Town: ".$result['town']."<br /></td>"; echo "<td bgcolor='#FFFFFF' style='color: #000' align='center'> Bedrooms: ".$result['rooms']."</td>"; echo "<td> </td>"; echo "<td bgcolor='#FFFFFF' style='color: #000' align='center'> Bathrooms: ".$result['bath']."<br /></td>"; echo "<td bgcolor='#FFFFFF' style='color: #000' align='center'> Square Footage: ".$result['square']."<br /></td>"; echo "<td bgcolor='#FFFFFF' style='color: #000' align='center'> Rent: ".$result['rent']."<br /></td>"; echo "<td bgcolor='#FFFFFF' style='color: #000' align='center'> Listed On: ".$result['time']."<br /></td>"; echo "</tr></div>"; header("Content-type: image/jpeg"); echo "<td bgcolor='#FFFFFF' style='color: #000' align='center'> Listed On: ".$result['image1']."<br /></td>"; ?> Thanks I want to display thumbnails for a picture gallery and when user clicks on image the larger image opens in a new window. I can't find a straight answer on the php.net website. Can someone help? How can i display all the images in a certain directory and echo the image names. So if a new image is uploaded, it will still display without edited the gallery.php file. Cheers. Hi I tried to write a script: 1) to locate all directories in a directory (1 level) 2) with the function GetImages() I try to display the image(s) in the subfolder there are only images in the subfolder I guess I'm doing something wrong in the GetImages() with the glob function, can anyone check this ? Thanks in advance function GetImages($map) { $files = glob('$map/*.jpg'); //$files = glob("$map/*.*"); for ($i=0; $i<count($files); $i++) { $num = $files[$i]; echo '<img height="50" width="50" src="'.$num.'" />'." <br />"; } } if ($handle = opendir('mystuff')) { /* loop through directory. */ while (false !== ($dir = readdir($handle))) { if($dir != ".." && $dir != "."){ echo '<option value='.$dir.'>'.$dir.'</option><br>'; GetImages($dir); } } closedir($handle); } I want to retrieve an image id from a db and show the images. I cant get the syntax right for the image tag.Any help appreciated. Code: [Select] function display_covers() { global $wpdb; $query = "select * from wp_cover"; $result = mysql_query($query)or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); echo mysql_error(); if (!$result) return false; echo'<div class="wrap"><p>choose from one of the covers below</p></div>'; echo'<div id="main">'; echo'<table class="main" cellpadding="2">'; //echo"<caption>Please choose a book cover</caption>"; ?> <thead><tr><td colspan="5" ><h6 class="main">Book Covers</h6></td></tr> </thead> <?php $i=0; $size=3; echo "<tbody>"; echo "<tr>"; while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) { /* display picture */ ?> <td class="main"> <?php echo"<img src="/Applications/MAMP/htdocs/wordpress_3/wp-content/plugins/Authors2/jackets/"{.$row['pix'].}""/>"; echo"</td>"; $i++; if($i==$size) { echo "</tr><tr>"; $i=0; } } } Hi everyone!! I have looked into how the upload script works and this is what i have: Code: [Select] <?php if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 20000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } ?> Which is un-tested at the moment, but let's just say for talking sake it worked 100% what elements of this script would i be looking at to display the files uploaded on to another page, in my case my homepage? ive found as to yet, that the uploads have to be stored on a file somewhere on my server, which i've set up. But i thought it would be just as easy to have a field in my table named upload and display it within the table next to the other results? instead i just get whatever the file name is named.jpg. Any help in looking towards the answer? many thanks in advance guys! Hi all, Newbie here, i am having a problem to get my images to show which are stored in mysql database as a mediumblob. I get id number to print in table ut am just getting empty square with red cross in where my image should be. Is my code incorrect or is it something else? Appreciate your help with this. I have included both of the pages codes i am using. Thanks Tony image2.php <?php include("common.php"); error_reporting(E_ALL); $link = mysql_connect(host,username,password) or die("Could not connect: " . mysql_error()); mysql_select_db(db) or die(mysql_error()); $sql = "SELECT id FROM photos"; $result = mysql_query("$sql") or die("Invalid query: " . mysql_error()); ?> <table border="1"><tr><td>id</td><td>image</td></tr> <?php while($row=mysql_fetch_assoc($result)){ print '<tr><td>'.$row['id'].'</td><td>'; print '<img src="image1.php?id='.$row['id'].'height="75" width="100"">'; } echo '</td></tr></table>' ?> image1.php <?php ob_start(); include("common.php"); mysql_connect(host,username,password) or die(mysql_error()); mysql_select_db(db) or die(mysql_error()); $query = mysql_query("SELECT imgage FROM photos WHERE id={$_GET['image_id']}"; $row = mysql_fetch_array($query); $content = $row['image']; header('Content-type: image/jpg'); echo $content; } ob_end_flush(); ?> Hello everyone, I need help figuring out why im not getting images displayed. I have tried everything I could think of and narrowed down the issue. What Im doing id querying urls from DB for my images. Then using md5 to encrypting the url them before display on web page. Here is the code: Code: [Select] $img = @ md5(mysql_result(mysql_query("SELECT `url` FROM `pictures` WHERE `mls`='{$row['mls']}' ORDER BY `id` LIMIT 1",$avenu->link),0)); When html is displayed I get the hash.jpg. The image failed to be loaded. I have a supplement store that we'll call SiteA . On the homepage there is a list of featured and best selling products with images. I have a separate blog that we'll call SiteB. I want to get the images and the url they link to (for the product page) from SiteA and display them on SiteB. So that when a user is browsing SiteB and they click on one of the product images, it takes them to the correct product page. I have a script where I can manually accomplish this. However, since the content on the homepage of SiteA is always changing, I'd like to automate this process. For example: If you do a google search for "php", then click on "images" at the top, you will see a list of images relevant to PHP. If you click on any one of them, it takes you to that images page. That is what I want to essentially accomplish. Any suggestions? I want to display 3 clickable images in a single row which repeats as long as there is data in the database, so far it is displaying a single clickable image from the database. below is all the code.. <table width="362" border="0"> <?php $sql=mysql_query("select * from `publication` GROUP BY `catsue`") or die(mysql_error()); $num=mysql_num_rows($sql); while($rowfor=mysql_fetch_array($sql)) { $cat=$rowfor['catsue']; $pic=mysql_query("select * from `category` where `catsue`='$cat'") or die(mysql_error()); $picP=mysql_fetch_array($pic); $base=basename($picP['title']); ?> <tr> <td width="352" height="88"><table width="408" border="0"> <tr> <td width="113" rowspan="5"><a href="archive_detail.php?id=<?php echo $rowfor['id'];?>&category=<?php echo $rowfor['catsue'];?>"><img src="ad/pic/<?php echo $base;?>" width="100" height="100" border="0"/></a></td> <td width="94">Title</td> <td width="179" height="1"><?php echo $rowfor['catsue'];?> </td> </tr> <tr> <td> </td> <td width="179" height="3"> </td> </tr> <tr> <td> </td> <td width="179" height="8"> </td> </tr> <tr> <td> </td> <td width="179" height="17"> </td> </tr> <tr> <td> </td> <td width="179" height="36"> </td> </tr> </table></td> </tr> <?php }?> </table> |