473,379 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

multiple tables in one page

imarkdesigns
Good day to all MASTERS!!

i have a simple problem here right now, and i think any PHP/MySQL Masters here can help me...

anyway, i have 3 tables in 1 Database. category1 , category2 , and category3 . these tables will be viewed in one page. but the problem is, how can i possibly code this? anyone?

here is my actual coding before... if there's any corrections... i appreciate it very much !

[PHP]$query = "SELECT category1.*, category2.*, category3.* FROM `category1` INNER JOIN `category2` IN `category1` = `category2` INNER JOIN `category3` IN `category3` = `category2` ORDER BY `id` DESC LIMIT $offset, $rowsPerPage";[/PHP]

by the way, this code is under and running by pagination..
Nov 6 '07 #1
6 1977
code green
1,726 Expert 1GB
I think you have got a bit confused with your query.
You connect to a Database then select Fields from Tables.
If they are three similar tables a UNION looks promising.
Can't give a query because I can't work out what you are trying to do.
[PHP]$query = "SELECT category1.*, category2.*, category3.* FROM `category1` INNER JOIN `category2` IN `category1` = `category2` INNER JOIN `category3` IN `category3` = `category2` ORDER BY `id` DESC LIMIT $offset, $rowsPerPage";[/PHP]But Use ON not IN with a JOIN.
You cannot ORDER BY something you haven't selected
Nov 6 '07 #2
hhmm....

ok... (by the way, im not a developer or programmer :( so it is not very easy for me to understand all type of codings here but i will try my best)

i have these categories in database, categery1, category2 and category3... what i want to do is to mix (not combine although their values are all same) these 3 tables in one page..

now, i just wondering how can i possibly write the exact code for this that will display mixture of 3 categories in one page...
Nov 6 '07 #3
here is my full actual codes.. and i use only 1 category

[PHP]
<?php

include 'admin/library/config.php';
include 'admin/library/opendb.php';

$query = "SELECT * FROM `category1` ORDER BY `id` DESC ";
$result = mysql_query($query) or die('Error, insert query failed');

while($rows = mysql_fetch_array($result)) {

?>
<div class="list1">

<div class="thumbs">
<form action="description.php" method="get">
<input type="image" src="box/<? echo $rows['name']; ?> " />
<input type="hidden" name="id" value="<? echo $rows['id']; ?>" />
</form>
</div>
<ul class="connection">
<li class="ctitle"><a href="<? echo $rows['website']; ?>" target="_blank"><? echo $rows['title']; ?></a></li>
<li class="category"><? echo $rows['category']; ?></li>
</ul>
</div>
<?php

}
include 'admin/library/closedb.php';

?>

[/PHP]
Nov 6 '07 #4
pbmods
5,821 Expert 4TB
You cannot ORDER BY something you haven't selected
Sure you can. As long as the table(s) that contains the field(s) is (are) part of the query.
Nov 6 '07 #5
code green
1,726 Expert 1GB
You cannot ORDER BY something you haven't selected
Sure you can. As long as the table(s) that contains the field(s) is (are) part of the query
Aaaarrrgh. Sorry pbmods imarkdesigns.
I was getting confused with GROUP BY and aggregation.
what i want to do is to mix (not combine although their values are all same) these 3 tables in one page
Not quite sure what you are doing,
but if you are selecting the same number of fields from the three tables a UNION may work [PHP]$query = "SELECT * FROM `category1` ORDER BY `id` DESC
UNION SELECT * FROM `category2` ORDER BY `id` DESC
UNION SELECT * FROM `category3` ORDER BY `id` DESC ";[/PHP]
Please check I got the syntax right.
I don't want pbmods shouting at me again
Nov 7 '07 #6
Markus
6,050 Expert 4TB
When pbmods shouts, he breaths a breath of knowledge and a shower of evermore knowledgable spit, over your face.

Feel blessed!
Nov 7 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Rick Caborn | last post by:
Does anyone know of a way to execute sql code from a dynamically built text field? Before beginning, let me state that I know this db architecture is built solely for frustration and I hope to...
16
by: lostinspace | last post by:
Is it possible? TIA
3
by: Yul | last post by:
Hi, We are in the process of designing an ASP.NET app, where a user will enter some 'Customer ID' to be queried in the database. If the ID is valid, several stored procedures will be called to...
3
by: Nick | last post by:
Hi, I am working on an eCommerce site, and the home page is split into multiple sections (user controls), whose data is provided from the database. Potentially this page will be cached, but its...
9
by: Graham | last post by:
I have been having some fun learning and using the new Controls and methods in .Net 2.0 which will make my life in the future easier and faster. Specifically the new databinding practises and...
1
by: sneha123 | last post by:
There will be some 20 questions and for each question there will be 4 choices.what i want to do is to select multiple answers by clicking the checkbox. i m using asp.net,vb.net pls help me we...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
3
by: rallykarro | last post by:
Hi, How do I at the best way perform select statements over multiple databases? I have a couple of databases containing the same table definitions with diffrent data. Now I want them to act...
0
chumlyumly
by: chumlyumly | last post by:
Hello scripters - OS: Mac OSX Language: PHP w/ MySQL database I've created an insert page where a user inputs his info, which then goes to four different tables in a MySQL database. The...
1
by: jcf378 | last post by:
Hi all-- Does anyone have any insight as to how I might create a search form that allows a user to select criteria based on any related table in the whole database. The search form I have now only...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.