473,320 Members | 1,868 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,320 software developers and data experts.

how can I display more than one image in my table???

Hi everybody???

I work on a search engine for my site. everything going good except for one thing. I have multiple image for each item to show. but each item have a different number of picture.

how can I display them. also what will be the way to store them.

actually i store 1 image in my database ( in fact it the path of the picture not the picture itself )

and my code goes like that..

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. include_once("db_connection.php");
  4.    if(isset($_POST['submit'])){   
  5.    if(isset($_GET['go'])){   
  6.    if(preg_match("/^[  a-zA-Z]+/", $_POST['name'])){   
  7.    $name=$_POST['name'];   
  8.  
  9.      //-query  the database table   
  10.    $sql="SELECT  kit_id, kit_number, kit_name, description, manufacturer_kit, manufacturer_reel, engine_detail, year_prod_kit, year_prod_reel, scale, image_id  FROM kit WHERE kit_name LIKE '%" . $name ."%' OR description LIKE '%" . $name .  "%' OR manufacturer_kit LIKE '%" . $name ."%'";  
  11.  
  12.  
  13.   //-run  the query against the mysql query function   
  14.    $result=mysql_query($sql);  
  15.  
  16.   //-make the header of the table   
  17.  
  18.    echo "  <table align=center width=\"100%\" border=\"\">\n";
  19.    echo "    <tr>\n";
  20.    echo"  <td nowrap align=center width='95'>  kit manufacturer  \n";        
  21.    echo"  <td nowrap align=center width='55'>    scale \n";        
  22.    echo"  <td nowrap align=center width='90'>    kit number \n";        
  23.    echo"  <td nowrap align=center width='290'>    kit name \n";        
  24.    echo"  <td nowrap align=center width='400'>    description \n";        
  25.    echo"  <td nowrap align=center width='70'>    year of reel production of car \n";        
  26.    echo"  <td nowrap align=center width='70'>    complete engine detail\n";        
  27.    echo"  <td nowrap align=center width='75'>    Select Picture to get bigger\n";
  28.    echo "    <tr>\n";
  29.  
  30.    //-create  while loop and loop through result set   
  31.    while($row=mysql_fetch_array($result)){   
  32.          $description  =$row['description'];   
  33.          $manufacturer_kit=$row['manufacturer_kit'];   
  34.          $kit_id=$row['kit_id']; 
  35.          $kit_number=$row['kit_number'];
  36.          $kit_name=$row['kit_name'];
  37.          $engine_detail=$row['engine_detail'];
  38.          $year_prod_reel=$row['year_prod_reel'];
  39.          $scale=$row['scale'];
  40.          $image_id=$row['image_id'];
  41.  
  42.    //-create  table of item during the while loop
  43.  
  44. echo "  <table align=center width=\"100%\" border=\"\">\n";           
  45. echo"  <td nowrap align=center width='95'>  $manufacturer_kit  \n";        
  46. echo"  <td nowrap align=center width='55'>    $scale \n";        
  47. echo"  <td nowrap align=center width='90'>    $kit_number \n";        
  48. echo"  <td nowrap align=center width='290'>    $kit_name \n";        
  49. echo"  <td nowrap width='400'>    $description \n";        
  50. echo"  <td nowrap align=center width='70'>    $year_prod_reel \n";        
  51. echo"  <td nowrap align=center width='70'>    $engine_detail \n";        
  52. echo"  <td nowrap width='75'> <a href=".$image_id.">   <img src='".$image_id."' width='75' height='50'/>";        
  53. echo "    </tr>\n";
  54. echo "    </table>\n"; 
  55. echo "    </tr>\n";
  56. echo "    </table>\n"; 
  57.  
  58.    }   
  59.    }  
  60.    else{   
  61.    echo  "<p>Please enter a search query</p>";   
  62.    }   
  63.    }   
  64.    }
  65.  ?>

So what will be the best way to do my need.

yours

sebastien
Jul 4 '10 #1
2 1687
TheServant
1,168 Expert 1GB
Well, I imagine that you don't want to have a limited number fo pictures for each item, so all I can think of is making a string of related pictures in the single database cell.

It's easier if you said for example there is a maximum number of 3 pictures per item, and then have 3 columes in your database for pic1, pic2 and pic3 (which you can call quite easily).

However, if you have an unknown number and it could be between 0 and 10,000 then you will need something more complicated.

Seeing as you're storing the path instead of the pictures, this is a bit easier. You can store the paths as a string and then separate them using explode().

So you would have a value in the database like:
"pics/pic1.jpeg , pics/pic2.jpeg , pics/pic3.jpeg"
and then explode it into an array with:
Expand|Select|Wrap|Line Numbers
  1. $pics = explode(" , ", $database_pics_string);
And then you can cycle through the $pics[] array to output all the elements as pictures.

Hope that helps.
Jul 5 '10 #2
thank I will try that and let you know

yours

sebastien
Jul 6 '10 #3

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

Similar topics

3
by: adam | last post by:
Hi, I have an issue that i just cant seem to figure out hope some one can help. right i am getting people to input the own images directly into a blob within a mysql database. then on the next...
3
by: Jeff Napier | last post by:
Hi, This works: banner = getImage(GetCodeBase(),"mypicture.jpg") But, I tried variations of: try { url = new URL("http://www.my-other-website.com/mypicture.jpg");
9
by: Wally | last post by:
I am trying to display images from an Access 2000 database and I get an error "Invalid Parameter Used" when I execute the code line "picBLOB.Image = Image.FromStream(stmBLOBData)" in my Visual...
1
by: bborden | last post by:
Novice Access programmer here. I would like to display an image using the Toolbox Image object by calling the images file name using: =fPictureFiles(!!,1) in the Picture control. Below...
1
by: Dev | last post by:
Dear Friends, I am passing the image name, size (in bytes) and imgaeformat (like jpg or bmp or pdf) through the network. I want display the image into picturebox without saving image...
18
by: Auto | last post by:
Hello, I would like to know how do display an image into a Gridview (ASP.NET 2.0) taken directly from a DataBase, NOT using an URL, like described in this article: ...
1
by: rajbala.3399 | last post by:
Hai all, I need to get multiple image buttonsand wheni click on the image button it should display corresponding image on window and if i click another image button it is also display on same...
3
by: computer_guy | last post by:
Hi Everyone, I run into a problem. I am trying to write an aspx that can dynamically generate an image based on some input parameters. Things are very simple if the size of the parameters is...
1
by: nanaalwi | last post by:
Hi, Currently I'm developing a software using VB.net that can grab an image using Matrox Morphis card and display it in a PictureBox. The software can grab the image already and display it in the...
5
by: RuiT | last post by:
Hello, I'm uploading images to a folder and I want to display each new image on a web page every time it is saved in the folder. I can display the initial image, which is already in the folder,...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.