How can I collect data from multiple tables on bluevoda? I am trying to get data from 2 tables from 1 database but I tried a few ways but didn't work, how will I be able to collect the data from 2 tables in the same database?
How to collect data from multiple tables?
Collapse
X
-
How to collect data from multiple tables?
Check out:
Great Windmill (A Place Where You Can Have Fun!)
You can do so much on the website, check it out!Tags: None
-
-
Re: How to collect data from multiple tables?
you have to have a script on the page laying it out.
Karen
VodaHost
Your Website People!
1-302-283-3777 North America / International
02036089024 / United Kingdom
291916438 / Australia
------------------------
Top 3 Best Sellers
Web Hosting - Unlimited disk space & bandwidth.
Reseller Hosting - Start your own web hosting business.
Search Engine & Directory Submission - 300 directories + (Google,Yahoo,Bing)
-
-
Re: How to collect data from multiple tables?
I'm not sure what you mean. The easy way is to retrieve the data from the two tables, separately, using "WHERE" clauses to make sure that you retrieve the right ones, then, once you have the data, you can display them in your page.
Since you are not givin any info on what you are trying to do, what scripts you are using etc, it is not easy to advise you.Navaldesign
Logger Lite: Low Cost, Customizable, multifeatured Login script
Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!
Comment
-
-
Re: How to collect data from multiple tables?
Originally posted by navaldesign View PostI'm not sure what you mean. The easy way is to retrieve the data from the two tables, separately, using "WHERE" clauses to make sure that you retrieve the right ones, then, once you have the data, you can display them in your page.
Since you are not givin any info on what you are trying to do, what scripts you are using etc, it is not easy to advise you.
PHP Code:$sql = "SELECT * FROM name,frame WHERE name='$user' or name='$us'";
Check out:
Great Windmill (A Place Where You Can Have Fun!)
You can do so much on the website, check it out!
Comment
-
-
Re: How to collect data from multiple tables?
Originally posted by navaldesign View PostI'm not sure what you mean. The easy way is to retrieve the data from the two tables, separately, using "WHERE" clauses to make sure that you retrieve the right ones, then, once you have the data, you can display them in your page.
Since you are not givin any info on what you are trying to do, what scripts you are using etc, it is not easy to advise you.Check out:
Great Windmill (A Place Where You Can Have Fun!)
You can do so much on the website, check it out!
Comment
-
-
Re: How to collect data from multiple tables?
Try
PHP Code:$sql = "SELECT * FROM name, frame WHERE name.name=frame.name AND name.name='$user' OR name.name='$us'";
Register/Login Script
Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script
Comment
-
-
Re: How to collect data from multiple tables?
you can collect data from the tables by:
$result = mysql_query ( "SELECT * FROM `table1` WHERE 1");
$result = mysql_query ( "SELECT * FROM `table2` WHERE 1");
you can then extrat the info from them by
$row = mysql_fetch_array($result);
Comment
-
-
Re: How to collect data from multiple tables?
Originally posted by Watdaflip View PostTry
PHP Code:$sql = "SELECT * FROM name, frame WHERE name.name=frame.name AND name.name='$user' OR name.name='$us'";
PHP Code:<?php
$rec_limit = 10;
$conn = mysql_connect("localhost","user","password");
if (!$conn)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("oieieais_Comment", $conn);
$sql = "SELECT count(id) FROM $useri, $username WHERE name='$username' or name='$useri'";
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not get data: ' . mysql_error());
}
$row = mysql_fetch_array($retval, MYSQL_NUM );
$rec_count = $row[0];
if( isset($_GET{'page'} ) )
{
$page = $_GET{'page'} + 1;
$offset = $rec_limit * $page ;
}
else
{
$page = 0;
$offset = 0;
}
$left_rec = $rec_count - ($page * $rec_limit);
$sql = "SELECT *".
"FROM $useri, $username WHERE name='$username' or name='$useri'".
" ORDER BY tm DESC LIMIT $offset, $rec_limit";
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not get data: ' . mysql_error());
}
while($nt=mysql_fetch_array($retval, MYSQL_ASSOC)){
}
mysql_close($conn);
?>Check out:
Great Windmill (A Place Where You Can Have Fun!)
You can do so much on the website, check it out!
Comment
-
-
Re: How to collect data from multiple tables?
Well I still don't know your table structure so I can't say exactly what your query should be, but heres some problems with your script
1) You are using variables for your tables in your sql query. While you can do this, your using the same variables as column values and neither have been set to anything. If you look closly at what I posted before the tables that you are selected need to be specified with the columns, look at the color coding.
"SELECT * FROM name, frame WHERE name.name=frame.name AND name.name='$user' OR name.name='$us'"
Blue is the table, red is the column your selecting
2) Your logic for getting the correct page is wrong, instead of doing
PHP Code:if( isset($_GET{'page'} ) )
{
$page = $_GET{'page'} + 1;
$offset = $rec_limit * $page ;
}
else
{
$page = 0;
$offset = 0;
}
PHP Code:$page = $_GET['page'];
if($page < 1)
{
$page = 1;
}
$offset = $rec_limit * ($page - 1);
3) I don't know if you were using $left_rec somewhere, but its not being used in that script, you can get rid of it.
4) When your retrieving your url variable with GET you are using curly brackets. While this is valid syntax, you should always try to follow normal programming convention and use square brackets with arrays.
Register/Login Script
Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script
Comment
-
Comment