co.ador Posted February 7, 2010 Share Posted February 7, 2010 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 https://forums.phpfreaks.com/topic/191204-help-with-a-where-clause-and-numerical-indexes/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.