I have a business directory in the making. I am having problems with displaying the results.
When a query is executed I can return the basic details I have asked for, however I wish for a few extras to be viewable.
I have 2 database entry types:
- Basic Entry
- Advanced entry
All of there details are stored in the same table with one column titled 'paid'. If the business is an advanced entry the row will state 'paid', if they are a basic entry it will state 'unpaid'.
All good so far....
So, when the query is executed I firstly want to display the following details for advanced listing:
Business Name
Address
Telephone
Fax
Email
Website
Features
Category
and then followed by the basic entry details:
Business Name
Address
Telephone
Category
In regards to the order, that is easy enough, but how do i display the 2 separate results together. i have managed to get it to work and be able to view one or the other but not together.
Can anyone help?
Cooper
multiple viewing of mysql data
Moderator: General Moderators
- cooper3000
- Forum Newbie
- Posts: 8
- Joined: Wed Jan 18, 2006 5:16 am
- Location: London
- raghavan20
- DevNet Resident
- Posts: 1451
- Joined: Sat Jun 11, 2005 6:57 am
- Location: London, UK
- Contact:
The problem is clear but how do you want to display...
some thing like...
advanced listings:
Business Name Address Telephone Fax Email Website Features Category
1st record
2nd record
and so on...
normal listings:
Business Name Address Telephone Category
1st record
2nd record
and so on...
else you want something like this...
Business Name Address Telephone Fax Email Website Features Category
advanced entry has all these fields filled
normal entry has null in email, website and features fields
here is the code...
some thing like...
advanced listings:
Business Name Address Telephone Fax Email Website Features Category
1st record
2nd record
and so on...
normal listings:
Business Name Address Telephone Category
1st record
2nd record
and so on...
else you want something like this...
Business Name Address Telephone Fax Email Website Features Category
advanced entry has all these fields filled
normal entry has null in email, website and features fields
here is the code...
Code: Select all
$query = "select * from table_name";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result)){
if (result["paid"] == "paid"){
echo "$result['businessname']\t $result['Address']\t $result['Telephone']\t $result['Fax']\t $result['Email']\t $result['Website']\t $result['Features']\t $result['Category']";
}else{
echo "$result['businessname']\t $result['Address']\t $result['Telephone']\t \t \t \t \t \t \t \t \t $result['Category']";
}
}- cooper3000
- Forum Newbie
- Posts: 8
- Joined: Wed Jan 18, 2006 5:16 am
- Location: London
- raghavan20
- DevNet Resident
- Posts: 1451
- Joined: Sat Jun 11, 2005 6:57 am
- Location: London, UK
- Contact:
you have to consider pagination for this model...
Code: Select all
$query = "select * from table_name";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result)){
if (result["paid"] == "paid"){
echo "$result['businessname']\t $result['Address']\t $result['Telephone']\t $result['Fax']\t $result['Email']\t $result['Website']\t $result['Features']\t $result['Category']";
}
mysql_data_seek($result, 0);
while($row = mysql_fetch_assoc($result)){
if (result["paid"] != "paid"){
echo "$result['businessname']\t $result['Address']\t $result['Telephone'] \t $result['Category']";
}
}- cooper3000
- Forum Newbie
- Posts: 8
- Joined: Wed Jan 18, 2006 5:16 am
- Location: London
- cooper3000
- Forum Newbie
- Posts: 8
- Joined: Wed Jan 18, 2006 5:16 am
- Location: London
I have done it:
while($row = mysql_fetch_assoc($result)){
if (result["paid"] == "paid"){
echo "$result['businessname']\t $result['Address']\t $result['Telephone']\t $result['Fax']\t $result['Email']\t $result['Website']\t $result['Features']\t $result['Category']";
}
}
mysql_data_seek($result, 0);
while($row = mysql_fetch_assoc($result)){
if (result["paid"] != "paid"){
echo "$result['businessname']\t $result['Address']\t $result['Telephone'] \t $result['Category']";
}
}
All i did was add the '}' in bold (bold to show you which one).
Thanks very much for all your help
Cooper
while($row = mysql_fetch_assoc($result)){
if (result["paid"] == "paid"){
echo "$result['businessname']\t $result['Address']\t $result['Telephone']\t $result['Fax']\t $result['Email']\t $result['Website']\t $result['Features']\t $result['Category']";
}
}
mysql_data_seek($result, 0);
while($row = mysql_fetch_assoc($result)){
if (result["paid"] != "paid"){
echo "$result['businessname']\t $result['Address']\t $result['Telephone'] \t $result['Category']";
}
}
All i did was add the '}' in bold (bold to show you which one).
Thanks very much for all your help
Cooper