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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

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.