Jump to content

Help with a WHERE clause and numerical indexes...


co.ador

Recommended Posts

Guys I am kind of confuse here.

 

 

I have set the following

 

This is what i have in cater table

 

 

CREATE TABLE IF NOT EXISTS `catertray` (

  `id` int(1) NOT NULL,

  `price` decimal(9,2) NOT NULL

) ENGINE=MyISAM DEFAULT CHARSET=latin1;

 

INSERT INTO `cater` (`id`, `price`) VALUES

(1, 13.90),

(1, 19.34),

(1, 28.12);

 

<?php 
$query3 = "SELECT cater.id, cater.name, cater.price, cater.ap_id
FROM caridadcaterin
WHERE
ap_id= " . (int) $_GET['menu']; 
$result = mysql_query($query3, $connection);
while ($row4 = mysql_fetch_array($result)) {
echo'<p class="name">Name:</p><p class="p">'. $row4['name'] . '</p>';

$query4 = "SELECT catertray.id, catertray.price
FROM catertray
WHERE
id= " ; 
$result = mysql_query($query3, $connection);
$row5 = mysql_fetch_assoc($result);
echo'
<div class="iteration">
<div class="small">
<p class="size">Small Tray</p>
<img src="images/bandeja2.jpg" width="80" height="90"/>
<p class="price">'. $row5['price'] . '</p>
</div>
<div class="medium">
<p class="size2">Medium Tray</p>
<img src="images/bandeja2.jpg " width="130" height="140"/>
<p class="price">'. $row5['price'] . '</p>
</div>
<div class="large">
<p class="size3">Large Tray</p>
<img src="images/bandeja2.jpg" width="150" height="180"/>
<p class="price">'. $row5['price'] . '</p>
</div>
</div>';
}
?>

Above I have the id as the relational database foreing key because otherwise I will have to reareange the other tables related to this one and they have a lot of information already. It hink I won't need a id with a primary key at the moment at cater table. With that said I have thought if it is better to instead of assigning a row for each price to put all the price in one row in three different indexes [0], [1],[2] and then assign the index number in the html to display WHERE id=id in cater table. Can you see the cater.id? I want to compare in the WHERE clause at the second query or $query4

 

$query4 = "SELECT catertray.id, catertray.price
FROM catertray
WHERE
id= cater.id" ;

 

The above example is just an idea on what I want to compare it with. I know some kind of Global variable could be used in there to extract the cater.id value from the first query. Should I define a variable with the cater.id as a value in between the two queries? then compare it in at the WHERE clause in the second query?

 

Thank you.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.