473,813 Members | 3,190 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

multiple tables in one page

imarkdesigns
46 New Member
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 1991
code green
1,726 Recognized Expert Top Contributor
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
imarkdesigns
46 New Member
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
imarkdesigns
46 New Member
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($qu ery) or die('Error, insert query failed');

while($rows = mysql_fetch_arr ay($result)) {

?>
<div class="list1">

<div class="thumbs">
<form action="descrip tion.php" method="get">
<input type="image" src="box/<? echo $rows['name']; ?> " />
<input type="hidden" name="id" value="<? echo $rows['id']; ?>" />
</form>
</div>
<ul class="connecti on">
<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 Recognized Expert Expert
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 Recognized Expert Top Contributor
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 Recognized Expert Expert
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
6220
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 make it better soon. Unfortunately, there is never a non-crucial time in which we can do an upgrade, so we are stuck for now. Point 1: There are multiple tables: students, courses, cross-reference
16
6904
by: lostinspace | last post by:
Is it possible? TIA
3
2706
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 populate multiple webpages containing customer information. There isn't a one-to-one correlation between the stored procedure and a webpage. In other words, a webpage may have to refer to 1 or more DataTables to populate itself. Therefore, a...
3
1571
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 not a user story yet, but I am still curious to know how people might render the page on the server, without having each user control issue its own database read query to get its own data. Are there best practices for this type of thing these...
9
2780
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 wizards. But, I have found that trying to do something "outside the norm" adds a rather large level of complexity and/or data replication. Background I have been commissioned to create a web-based application for a client. It has a formsaunthentication...
1
2927
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 have written the code using radio button for selecting single item.but we want to replace it with checkbox to select multiple items. the code using radio button is given below .pls correct it with checkbox
6
5003
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 for long running reports. When the processing is complete it uses crystal reports to load a template file, populate it, and then export it to a PDF. It works fine so far....
3
8701
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 as a single database giving me one answer on a select statement but the answer fetched from all my defined databases.
0
4457
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 tables are all linked with the field 'member_id', which is an auto-increment field in the parent table ('members'). I've been able to input multiple records into the other three tables 'specialty_groups', 'committee_interest' and 'committee_member'...
1
4173
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 allows me to filter based on variables in a single table. I would like to have a search form where I can select multiple variables (from various linked tables) to filter by, and return results based on this multi-table filter. Allen Browne...
0
10669
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10408
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10426
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9225
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6897
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5570
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5707
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4358
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3030
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.