Jump to content

navigation with changed series


vinpkl

Recommended Posts

hi all

 

i m creating navigation from database.

 

There are around 30 dealers names entered in database like

1) Nokia

2) Samsung

3) sony

 

continue till...

 

30) panasonic

 

but the problem is that in the navigation the names will not be displayed according to series they were entered.

 

So if i have to display the navigation according to changed series then i have to repeat this query 30 times.

 

Is there any other way to display and change series but not repeating the query 30 times.

 

vineet

 

<?php 
$leftqry="select * from dealer_table where category_id=1 and dealer_name='nokia'";
$leftresult=mysql_query($leftqry);
$leftrow=mysql_fetch_array($leftresult);
$category_id=$_REQUEST['category_id'];
echo "<tr>";
echo "<td>" . "<a class='leftnav'>&raquo  " .$leftrow['dealer_name']. "</a></td>";
echo "</tr>";
?>	

Link to comment
https://forums.phpfreaks.com/topic/174873-navigation-with-changed-series/
Share on other sites

I don't exactly follow 'changed series' do you mean they change order in your database? and if so why would it matter? but a solution to this problem being that there IS a low number of manufacturers, you could just pull all the fields from the db at once, then loop through them and do with the data whatever you want to do with it.

hi Russell

 

Yes 'Changed Series' means 'Changed order'.

 

means the dealer name entered at serial no. 1 will be at no. 5 and dealer name entered at serial no. 10 will be

 

at no.2.

 

so if i loop them in single query then they will display acording to the serial number they were entered.

 

like the below code will display only one manufacturer 'Nokia'

 

<?php 
$leftqry="select * from dealer_table where category_id=1 and dealer_name='nokia'";
$leftresult=mysql_query($leftqry);
$leftrow=mysql_fetch_array($leftresult);
$category_id=$_REQUEST['category_id'];
echo "<tr>";
echo "<td>" . "<a class='leftnav'>&raquo  " .$leftrow['dealer_name']. "</a></td>";
echo "</tr>";
?>	

 

and below query will output all dealers acording to serial no. they were entered in database.

<?php 
$leftqry="select * from dealer_table where category_id=1";
$leftresult=mysql_query($leftqry);
while($leftrow=mysql_fetch_array($leftresult))
{
$category_id=$_REQUEST['category_id'];
echo "<tr>";
echo "<td>" . "<a class='leftnav'>&raquo  " .$leftrow['dealer_name']. "</a></td>";
echo "</tr>";
}
?>	

 

now how will i change their serial no. or order sequence.

 

vineet

 

 

I don't exactly follow 'changed series' do you mean they change order in your database? and if so why would it matter? but a solution to this problem being that there IS a low number of manufacturers, you could just pull all the fields from the db at once, then loop through them and do with the data whatever you want to do with it.

hi ignace

 

"order by category_id" will fetch results acording to category.

 

but i want to fetch results all dealers in one category and that i m able to do.

 

what i want to ask is after fetching how can i change their order sequence.

 

at My present i am able to set sequence with my below query.

 

But if i have 30 dealers then i have repeat this same query 30 times and it wil make my code very lenghty.

 

vineet

 

<?php

$leftqry="select * from dealer_table where category_id=1 and dealer_name='nokia'";

$leftresult=mysql_query($leftqry);

$leftrow=mysql_fetch_array($leftresult);

$category_id=$_REQUEST['category_id'];

echo "<tr>";

echo "<td>" . "<a class='leftnav'>&raquo  " .$leftrow['dealer_name']. "</a></td>";

echo "</tr>";

?>

 

vineet

 

SELECT * FROM dealer_table ORDER BY category_id

 

Altough I assume this is the default behavior if you don't specify any 'order by' rule

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.