473,408 Members | 1,826 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,408 software developers and data experts.

an array of data from two mysql tables

178 100+
Hi,

Im having trouble trying to figure out where to start with this problem. I have two tables.

module ={module_id, module_name, subtype, height, width, depth, mod_desc, confirmed}

object ={object_id, module_name, object_name, xpos, ypos, proj_id}

Given a value for proj_id I have to check wether any records in my table contain this value. If there are records that contain this value I need to create an array of the following {object_name, xpos, ypos, height, width}

Can anyone help me in creating this array? Heres my code so far

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. require "config.php";
  3.  
  4. // $proj = $_POST['proj'];
  5.  
  6. // Get how many records contain proj_id = proj
  7. $query = mysql_query("SELECT COUNT(*) FROM object WHERE proj_id = '4'");
  8. $result = mysql_fetch_row($query) or die(mysql_error()); 
  9. //echo "result: ".$result[0];
  10. // if zero do nothing
  11. if ($result != 0) {
  12.  
  13. }
  14.  
  15. ?>
Aug 21 '08 #1
1 1110
cleary1981
178 100+
Sorted. heres the code for future reference

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. require "config.php";
  3.  
  4. // $proj = $_POST['proj'];
  5. $proj_id = 77;
  6. // Get how many records contain proj_id = proj
  7. $query = mysql_query("SELECT COUNT(*) FROM object WHERE proj_id = $proj_id");
  8. $result = mysql_fetch_row($query) or die(mysql_error()); 
  9. // echo "result: ".$result[0];
  10. // if zero do nothing
  11. if ($result != 0) {
  12.     $results = mysql_query("SELECT object_name, xpos, ypos, height, width FROM object, module WHERE object.module_name = module.module_name AND proj_id=$proj_id") or die();
  13.     while($values = mysql_fetch_array($results)){
  14.      echo $values['object_name'] . '<br />';
  15.      echo $values['xpos'] . '<br />';
  16.      echo $values['ypos'] . '<br />';
  17.      echo $values['height'] . '<br />';
  18.      echo $values['width'] . '<br /><br />';
  19.     }
  20.  
  21. }
  22. ?>
Aug 21 '08 #2

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

Similar topics

12
by: James | last post by:
Hi, Have posted before, but will simplify problem here. For original post go to http://forums.devshed.com/t80025/s.html I have setup 2 arrays like so in my one page script: $carers =...
4
by: iannorton | last post by:
Hi, I've spent most of today trying to solve this problem, but sadly no luck. I have an shopping basket based on an array which stores the name, product id, quantity and price for products, i...
0
by: Erik Summers | last post by:
I am new to php/mysql but not new to server side scripting in general. I have built an app using DreamWeaver MX, PHP and MySQL. It is working well but there is one final functionality I need and...
0
by: Luc Foisy | last post by:
Last week many of our server and client servers had a power problem. Not = quite sure how the servers were handled, wasn't on site, but I don't = think some of these servers got shut down...
3
by: eieiohh | last post by:
MySQL 3.23.49 PHP 4.3.8 Apache 2.0.51 Hi All! Newbie.. I had a CRM Open Source application installed and running. Windows Xp crashed. I was able to copy the contents of the entire hard...
27
by: Cleverbum | last post by:
I currently have a list of md5 strings and need to check if a new string is in that list hundreds of thousands of times. I've found that the fastest way to do this is to have all the md5's stored...
6
by: craig.keightley | last post by:
i have the following array: Array ( =Array ( =Leamore Windows Ltd =553398833511417 =20 )
0
by: quantumlady | last post by:
Hi, All. I am working on a project with another student that will be used on Oracle, MySWL and DB2 databases. We have completed all the basic functions, but I would like to see if we can improve...
11
by: Chad | last post by:
Hi Is it possible to substitute an alternative data source (eg MySQL or SQL Server) into an existing MS-Access application?
10
by: darkenroyce | last post by:
Hi Guys I am creating a sports database and one of the features involves create drop down dialogue boxes that retrieve data from MySQL tables and provides them as <option> within...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.