|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||||
|
|||||
|
sortring and displaying sql results
Hello,
I am a newbie-- I am trying to print out a list of restaurant--sorted by the type of restaurant. But I think I'm making this too complicated. When I use sort on sql--only the first row is printed. I want to pull up all of the restaurants for a particular state and then print out the results according to the type of restaurant--for instance-- Chinese Restaurants My Huang Choo Choo Indian Restaurants Indoo Inn Chutney Central Isle of India Italian Restarants Lil Italy Spagetti Inn Pizza and Stuff This is the code I have so far--all it does it pull up the restaurants--I want it to sort by the cuisine php Code:
|
|
#2
|
|||
|
|||
|
RE: sortring and displaying sql results
You can use:
[CODE] SELECT * FROM table WHERE value = value ORDER BY cuisine |
|
#3
|
|||
|
|||
|
RE: sortring and displaying sql results
I don't understand what should go in the "value" field? Are you saying do three separate queries?
|
|
#4
|
|||
|
|||
|
RE: sortring and displaying sql results
Code:
$query = "SELECT cuisine,
name,
address,
phone,
url,
city
FROM restaurants
WHERE state = $statnum"
ORDER BY cousine;
This will display your output ordered by cuisine. If you want i in reverse order you type ORDER BY cuisine DESC |
|
#5
|
|||
|
|||
|
RE: sortring and displaying sql results
|
|
#6
|
|||
|
|||
|
RE: sortring and displaying sql results
It looks allright with a few alterations. Haven't tested it though.
Code:
<?php
if ($row[cusine] == "1") {
echo chinese restaurants
echo "<tr> <td bgcolor="#FFCC00">".
$row[name]. " " .
$row[address]. " ".
$row[city]. " ".
PH. " " .
$row[phone]. " ";
echo "</td></tr>";
}
echo "</table>";
if(!mysql_close($connection)) {
showerror();
}
?>
|
|
#7
|
|||||
|
|||||
|
RE: sorting and displaying sql results
I still can't get this--I've tried several ways this is the lastest it prints out all the rows--how do I check for one attribute and have it print based on that attribute???
php Code:
|
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > sortring and displaying sql results |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|