mendoz Posted December 14, 2006 Share Posted December 14, 2006 hey freaks.This is my table:[table][tr][td]id[/td][td]type[/td][td]name[/td][/tr][tr][td]1[/td][td][color=green]laptop[/color][/td][td]blah[/td][/tr][tr][td]2[/td][td][color=green]laptop[/color][/td][td]blah[/td][/tr][tr][td]3[/td][td][color=green]laptop[/color][/td][td]blah[/td][/tr][tr][td]4[/td][td][color=green]laptop[/color][/td][td]blah[/td][/tr][tr][td]5[/td][td][color=red]pc[/color][/td][td]blah[/td][/tr][tr][td]6[/td][td][color=red]pc[/color][/td][td]blah[/td][/tr][/table]Theire images are stored in directiories with "type" name: pc,laptop....there we have images with filenames like this 1.jpg,2.jpg....This is how I sommun the images:<img src="<?php echo $type/$id; ?>" alt="" />If I SELECT the laptop products it's all ok.But, if I select the pc type they start from 5 and I don't like it that much.I could use a for loop but inside the table I have a sub category called "manufacter" (amd,intel...),so basicly it just gives me the same images.This is theoreticaly what I want:[list][*]select all the rows where the type column equals pc[*]then to create a new index, like id 1,2,3,4[*]then to take only the ones where the manufacter='amd' (i.e 1,3)[*]then instead of staying with [1,2] I want to stay with [1,3] [/list]Hope you understand this.Thanks,Dror Link to comment https://forums.phpfreaks.com/topic/30646-freaks-come-here-need-logic-solution/ Share on other sites More sharing options...
mendoz Posted December 14, 2006 Author Share Posted December 14, 2006 I solved this in a disgusting way, but would like to hear your solutions :-* Link to comment https://forums.phpfreaks.com/topic/30646-freaks-come-here-need-logic-solution/#findComment-141215 Share on other sites More sharing options...
utexas_pjm Posted December 14, 2006 Share Posted December 14, 2006 Why not just include the image name in the table? Then you can name it whatever you want. Link to comment https://forums.phpfreaks.com/topic/30646-freaks-come-here-need-logic-solution/#findComment-141219 Share on other sites More sharing options...
mendoz Posted December 14, 2006 Author Share Posted December 14, 2006 yea... :-\you're right.[code]<code lang="he"/><?phpinclude "sql/conn.php";@mysql_select_db($db_name) or die( "Unable to select database");$cat=$_GET["cat"];$sug=$_GET["sug"];$query="SELECT * FROM pc WHERE type='$sug'";$result=mysql_query($query);$row=mysql_fetch_array($result);$num=mysql_numrows($result);mysql_close();?><div class="productlist"><div class="productlist2"><?php echo "$title > $cat"; ?></div></div><table id="table" style="vertical-align:top;padding:0px;text-align:center; margin-left:auto; margin-right:auto;"><?php for ( $j=0; $j < 2; $j++ ) { // This will be the number of the rows echo "<tr>"; for ( $i=$j*3+1; $i < $j * 3 + 4; $i++ ) { // This will be the number of the cells if ($i<=$num) { // $num is the total rows number $name=mysql_result($result,$i-1,"name"); $desc=mysql_result($result,$i-1,"description"); $short=mysql_result($result,$i-1,"short"); $manu=mysql_result($result,$i-1,"manufacter"); $id=mysql_result($result,$i-1,"id"); if ($manu==$cat) { //this check if the manufacter is the same as what was asked ?> <td> <div id="product"> <table id="table"> <tr> <td style="background:#ffffff;padding: 5px;width:170px"> <img src="<?php echo "$manu"; ?>.jpg" alt="" /> </td> </tr> <tr> <td> <div id="bgprod"> <a href="<?php echo "?page=product&type=$type&item=$i"; ?>"><?php echo "$name<br/>$desc"; ?></a> <br/><br/> <a href="?page=product&type=<?php echo "$type"; ?>&item=<?php echo "$i"; ?>"> <img src="test/phpThumb.php?src=../images/product/<?php echo "$sug/$i"; ?>.jpg&w=150&sia=custom-filename"></a> <a href="?page=product&type=<?php echo "$type"; ?>&item=<?php echo "$i"; ?>">ìîôøè äîìà</a></b> </div> </td> </tr> </table> </div> </td> <?php } ?> <?php } ?> <?php } ?></tr><?php } ?></table>[/code] Link to comment https://forums.phpfreaks.com/topic/30646-freaks-come-here-need-logic-solution/#findComment-141229 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.