tycy Posted December 2, 2014 Share Posted December 2, 2014 Hello All From the begin i have the following code. <?php $sql = "SELECT id,phonemodel FROM iphone"; $rows = $conn->sqlExec($sql); $nr_row = $conn->num_rows; $meniu ='<ul>'; if($nr_row>=0) { foreach($rows as $row) { $meniu .= '<li><a href="iphone.php?id='.$row['id'].'">'.$row['phonemodel'].'</a></li>'; } } $meniu .= '</ul>'; echo $meniu; if(isset($_GET['id'])) { $id = (int)$_GET['id']; $sql = "SELECT * FROM iphone WHERE id = $id"; $rows = $conn->sqlExec($sql); $nr_rows = $conn->num_rows; if($nr_rows>0) { foreach($rows as $row){ echo 'Name Tel: '.$row["phonemodel"].' Title : '.$row["titlereparation"].' Pret : '.$row["price"].' Message : '.$row["msj"].' ID : '.$row["id"].'<br />'; } } else { echo '0 Results'; } } ?> Basicaly i have a website for phone repairs.And i want to create in iphone.php a menu from DB and when i acces the menu with _GET variable, when i press Iphone 5s (iphone.php?id=id page) the code have to display to me,all reparations for iphone 5s. Until now,i succssed to create the Menu but the code keep add same line in the menu when i add for example a second reparation for 5s.And i don't know how to select all reparation for 5s and display them in a single link like above Iphone 5s (iphone.php?id=id page). Now the script working like this.Create a menu with all phone names. Iphone 5s Iphone 3 Iphone 3s Iphone 4 Iphone 5s Iphone 5s Shoud be like Iphone 5s Iphone 3 Iphone 3s Iphone 4 Other new devices.. And display the reparation in every link from list By ID.i try it to select by phone names,not working. Any body with any ideea please? Thx so much Link to comment https://forums.phpfreaks.com/topic/292844-create-a-menu-and-select-details-for-each-link/ Share on other sites More sharing options...
Barand Posted December 2, 2014 Share Posted December 2, 2014 try $sql = "SELECT DISTINCT id,phonemodel FROM iphone"; Link to comment https://forums.phpfreaks.com/topic/292844-create-a-menu-and-select-details-for-each-link/#findComment-1498294 Share on other sites More sharing options...
tycy Posted December 4, 2014 Author Share Posted December 4, 2014 Yes,it's working like this,but i have to select only phonemodel , looks like when you have more then 2 cols there not working.But that is not a problem for my,just i let you know maybe somebody need a thing like this. I didn't have time to say thx for the answer. So thx ! Link to comment https://forums.phpfreaks.com/topic/292844-create-a-menu-and-select-details-for-each-link/#findComment-1498482 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.