Jump to content

FREAKS COME HERE, need logic solution


mendoz

Recommended Posts

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

yea... :-\

you're right.

[code]<code lang="he"/>
<?php
include "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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.