473,395 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

how to put my images in a row, let's say 3 images in a row by using php

hi, if i use mysql_fetch_array, i can only fetch one row at a time and thus only retrieve one filename in database, thus show one image in the row of this filename.
my current code is like following:

Expand|Select|Wrap|Line Numbers
  1.  
  2. $getName = $_GET['name'];
  3.     if (isset($getName)){
  4.         $selPaint = "SELECT * from images where artist ='".$getName."'";
  5.     }
  6.     else{
  7.         $selPaint = "SELECT * from images";
  8.     }
  9.  
  10.     $execPaint = mysql_query($selPaint);
  11.  
  12.     if(isset($_SESSION['SESSuserid'])){ //if user logged in                 
  13.  
  14.         echo "<form action=\"do_addcart.php\" method=\"POST\"><br>";
  15.  
  16.         while($thisArt = mysql_fetch_array($execPaint)){
  17.             $fName = $thisArt['filename'];
  18.             echo "<h3>".$thisArt['title']."<h3><br>";
  19.             echo "<a href =".$uploaddir.$fName.">";
  20.             echo "<img src=".$thumbdir."thumb_".$fName."></a><br>";
  21.             echo "<input type=\"checkbox\" name=\"".$thisArt['id']."\" value=\"1\">";
  22.  
  23.  
  24.         echo "<input type =\"submit\" value=\"Select\"><br>";}
  25.         echo "</form>";        
  26.     }
  27.  
how can i retrieve more than one filenames and put 3 images in a row by using PHP.
the effect will something like the following website: http://www.coach.com/content/thumbna...ategory_id=900

can anyone help me with this, it is a bit urgent! :)
thanks in advance!
Aug 27 '07 #1
3 2886
ak1dnar
1,584 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1.  
  2. $getName = $_GET['name'];
  3.     if (isset($getName)){
  4.         $selPaint = "SELECT * from images where artist ='".$getName."'";
  5.     }
  6.     else{
  7.         $selPaint = "SELECT * from images";
  8.     }
  9.  
You do know how the "IF" function working here, right?

If you are passing URL parameters to this Script in this way;
http://yourdomain/thisScript.php?name=your_value
Expand|Select|Wrap|Line Numbers
  1.  SELECT * from images where artist ='".$getName."'";
Will execut.
If there is nothing on the "name" value
Expand|Select|Wrap|Line Numbers
  1.          $selPaint = "SELECT * from images";
will execute.

Before you create your 3 COLUMN structure, how about making this script to display the records.

Are you mentioning that your script ONLY shows One record on both conditions?
Aug 27 '07 #2
Expand|Select|Wrap|Line Numbers
  1.  
  2. $getName = $_GET['name'];
  3.     if (isset($getName)){
  4.         $selPaint = "SELECT * from images where artist ='".$getName."'";
  5.     }
  6.     else{
  7.         $selPaint = "SELECT * from images";
  8.     }
  9.  
You do know how the "IF" function working here, right?

If you are passing URL parameters to this Script in this way;
http://yourdomain/thisScript.php?name=your_value
Expand|Select|Wrap|Line Numbers
  1.  SELECT * from images where artist ='".$getName."'";
Will execut.
If there is nothing on the "name" value
Expand|Select|Wrap|Line Numbers
  1.          $selPaint = "SELECT * from images";
will execute.

Before you create your 3 COLUMN structure, how about making this script to display the records.

Are you mentioning that your script ONLY shows One record on both conditions?
No, this If function is working fine, it returns records i want, but the questions i ask is more towards how to 3 different images in a row, because the code

[code:PHP]

while($thisArt = mysql_fetch_array($execPaint)){
$fName = $thisArt['filename'];
echo "<h3>".$thisArt['title']."<h3><br>";
echo "<a href =".$uploaddir.$fName.">";
echo "<img src=".$thumbdir."thumb_".$fName."></a><br>";
}

[/code]

this code can only give me one image each time through the while loop, and one row one image, what i want to achieve is to have 3 different images in a row. i dont know how to write this kind of code. can help me with this, i will really appreciate your kind help! :)
Aug 27 '07 #3
ak1dnar
1,584 Expert 1GB
Please read through this tutorial.
Hope you may find the answer from there. If there is a doubt feel free to ask. Thanks and good luck.

Please use code tags in this format:

[code=php]

[code] put a / after the opening square bracket to close the code tags.
Aug 27 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: moondaddy | last post by:
Happy Holidays All! I want to load a datagrid with images and text (Image, text, image, text, etc...). The data for this datagrid will be coming from sql server and the images are stored as files...
2
by: Alex | last post by:
I have a web application hosted on the server's F:\www directory. I have images stored on the file system at E:\Images. I have the website shared thru IIS pointing to the F:\www directory. 1.)...
7
by: gemel | last post by:
I am developing an application that uses SQL 2000 as my source of images. I have successfully created the code to load the images onto the SQL Server and also to retrieve the images into a dataset....
5
by: david | last post by:
Can I use WriteFile methods? It seems that it does not work. For example, the following code only dispay one figure. Response.WriteFile("images/image002.jpg") Response.Write("<br><p>")...
18
by: Andrew Christiansen | last post by:
Hey all. The images I create in photoshop with semi-transparent pixels (for instance in Photoshop text with a dropshadow with a transparent canvas) I've been saving in PNG format and then using...
15
by: Jameson | last post by:
Happy New Year, Everyone! I am trying to figure out how to display a bunch of images (mainly JPEGs, but possibly a few GIFs and PNGs as well) that are stored in a local directory on the system....
10
by: Neo Geshel | last post by:
I am seeking to hand-roll my own blog in ASP.NET 2.0 and SQLExpress 2005. Why? Because I can. Because I will gain experience. The one thing that has me stumped at square one is inline images....
61
by: phil-news-nospam | last post by:
Why does SVG need a different tag than other images? IMHO, SVG should be implemented as an image type just like any other image type, allowing it to work with <img> tags, and ... here is the...
4
by: Bob Bedford | last post by:
Hi all, I'm stuck with some php code that runs out of time limit. This is due to a long XML file process that has to save pictures on the disk. What I've now: - read XML file - parse XML...
2
by: OBAFGKM_RNS | last post by:
Let's say I have a Javascript function that loops over and over. In that function i have it alternating images on a button this way: if(var==0){ var myHTML = "<input type='button'...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.