scaleautostyle Posted July 4, 2010 Share Posted July 4, 2010 NOw it's going to the good way. except for one thing. the code like I do it display only 1 picture. in fact in some case I have 2 picture on other 5, 3 8 etc.. I never know how many picture it will be display. I don't want to create 15 column and attribute a variable fo each image to get a result taht in a case I have 2 picture shown on the table and get 13 empty. I don't know if someone understand what I want to do. if yes some light is welcome. this is the working code <?php include_once("db_connection.php"); if(isset($_POST['submit'])){ if(isset($_GET['go'])){ if(preg_match("/^[ a-zA-Z]+/", $_POST['name'])){ $name=$_POST['name']; //-query the database table $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 ."%'"; //-run the query against the mysql query function $result=mysql_query($sql); //-make the header of the table echo " <table align=center width=\"100%\" border=\"\">\n"; echo " <tr>\n"; echo" <td nowrap align=center width='95'> kit manufacturer \n"; echo" <td nowrap align=center width='55'> scale \n"; echo" <td nowrap align=center width='90'> kit number \n"; echo" <td nowrap align=center width='290'> kit name \n"; echo" <td nowrap width='400'> description \n"; echo" <td nowrap align=center width='70'> year of reel production of car \n"; echo" <td nowrap align=center width='70'> complete engine detail\n"; echo" <td nowrap align=center width='75'> Select Picture to get bigger\n"; echo " <tr>\n"; //-create while loop and loop through result set while($row=mysql_fetch_array($result)){ $description =$row['description']; $manufacturer_kit=$row['manufacturer_kit']; $kit_id=$row['kit_id']; $kit_number=$row['kit_number']; $kit_name=$row['kit_name']; $engine_detail=$row['engine_detail']; $year_prod_reel=$row['year_prod_reel']; $scale=$row['scale']; $image_id=$row['image_id']; //-create table of item during he while loop echo " <table align=center width=\"100%\" border=\"\">\n"; echo" <td nowrap align=center width='95'> $manufacturer_kit \n"; echo" <td nowrap align=center width='55'> $scale \n"; echo" <td nowrap align=center width='90'> $kit_number \n"; echo" <td nowrap align=center width='290'> $kit_name \n"; echo" <td nowrap width='400'> $description \n"; echo" <td nowrap align=center width='70'> $year_prod_reel \n"; echo" <td nowrap align=center width='70'> $engine_detail \n"; echo" <td nowrap width='75'> <a href=".$image_id."> <img src='".$image_id."' width='75' height='50'/>"; echo " </tr>\n"; echo " </table>\n"; echo " </tr>\n"; echo " </table>\n"; } } else{ echo "<p>Please enter a search query</p>"; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/206692-how-can-i-do-a-loop-to-display-my-picture/ Share on other sites More sharing options...
trq Posted July 4, 2010 Share Posted July 4, 2010 Sorry, but your post makes little to no sense at all. Quote Link to comment https://forums.phpfreaks.com/topic/206692-how-can-i-do-a-loop-to-display-my-picture/#findComment-1080969 Share on other sites More sharing options...
scaleautostyle Posted July 4, 2010 Author Share Posted July 4, 2010 what you mean?? in my head is make sence... here is again with other word. each item have multiple image. but doesn't how many for wach item how can I display them... is it more sence like that?? yours sebastien Quote Link to comment https://forums.phpfreaks.com/topic/206692-how-can-i-do-a-loop-to-display-my-picture/#findComment-1080976 Share on other sites More sharing options...
Pikachu2000 Posted July 4, 2010 Share Posted July 4, 2010 So, what I'm getting is, you want to display all the pictures for each record. There might be one picture, or there might be 15. You want to display them in a way that varies to match the number of pictures, instead of having a fixed table of, say 3x5 cells, with 2 pictures and 13 empty cells. Is that about right? Quote Link to comment https://forums.phpfreaks.com/topic/206692-how-can-i-do-a-loop-to-display-my-picture/#findComment-1081008 Share on other sites More sharing options...
scaleautostyle Posted July 4, 2010 Author Share Posted July 4, 2010 So, what I'm getting is, you want to display all the pictures for each record. There might be one picture, or there might be 15. You want to display them in a way that varies to match the number of pictures, instead of having a fixed table of, say 3x5 cells, with 2 pictures and 13 empty cells. Is that about right? that's right because if I have to do a fix table I will get +- 23 column 7 of data and the other for picture. but only a few record +- 50% get the other 16 space the rest will took 6 - column. so it will not be a nice looking. thanks in advance for any input to solve the problem yours sebastien Quote Link to comment https://forums.phpfreaks.com/topic/206692-how-can-i-do-a-loop-to-display-my-picture/#findComment-1081010 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.