Jump to content

Create a Menu and Select Details for each link


tycy
 Share

Go to solution Solved by Barand,

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old.

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.

 Share

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