473,407 Members | 2,315 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,407 software developers and data experts.

How to connect two tables on php file.

1
Pls I need help. I got two tables on a database but I dont know how to run them independently. Please find below our script. It is a shipping tracking website. All I want is each table to run independently once tracked.

Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. //Connect To Database
  3. $hostname='localhost.com';
  4. $username='forexample';
  5. $password='xxxx';
  6. $dbname='example';
  7. $usertable='ECMY4572957';
  8.  
  9. mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.');
  10. mysql_select_db($dbname);
  11.  
  12. //This array contains all correct tracking numbers
  13. $track_number = $_POST['track_number'];
  14. if(empty($track_number)){
  15.     die('<b>Please go back & enter tracking number</b>');
  16. }
  17. else if(strlen($track_number) <= 0 || strlen($track_number) > 15){
  18.     die('<b>Invalid tracking number, please go back</b>');
  19. }
  20. else{
  21. $correct_tracking_numbers=array(ECMY4572957, BHSZ006933);
  22. if(in_array($track_number,$correct_tracking_numbers)){
  23.     $query = 'SELECT * FROM ' . $usertable;
  24.     $result = mysql_query($query) or die(mysql_error());
  25. echo "<table border='5'>
  26. <tr>
  27. <th>Date/Time</th>
  28. <th>Event</th>
  29. <th>Location</th>
  30. <th>Details</th>
  31. <th>Type of Move</th>
  32. </tr>";
  33.     while($row = mysql_fetch_array($result)){
  34. echo "<tr>";
  35.         echo "<td>" . $row['Date/Time'] .  "</td>";
  36. echo "<td>" . $row['Event'] .  "</td>";
  37. echo "<td>" . $row['Location'] .  "</td>";
  38. echo "<td>" . $row['Details'] .  "</td>";
  39. echo "<td>" . $row['Type of Move'] .  "</td>";
  40. echo "</tr>";
  41. }
  42. echo "</table>";
  43. echo "<br>";
  44. echo "<br>";
  45. echo "<br>";
  46. echo "<br>";
  47. echo "<br>";
  48.  
  49. }else{
  50.     echo '<b>The tracking number is invalid, Please go back & enter a Valid Tracking Number!</b>';
  51. }
  52. }
  53. ?>
  54. </body>
  55. </html>
How do I write or connect the second usertable to the php file as the first script which is working fine once tracked? The table name is "FTYX34555867". I don't know how to run or write multiple table on same database. All I need is, how to connect multiplt tables so each table can run different tracking number. Am stress as am not getting it well. Please help me.
Jun 5 '10 #1
1 1966
dlite922
1,584 Expert 1GB
What does the second table contain? same thing as the first?

Do you need to check each tracking number against both tables?

It's not clear "what" you want to do with the second table. You can't "run" tables. tables is just a collection of data. so what is this data and what do you want to do with it?


Dan
Jun 7 '10 #2

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

Similar topics

3
by: Rob Davis | last post by:
I am familiar with VBA and the manual method of attaching/linking external data tables (File, Get External Data etc). I am also familiar with opening tables which exist in the current Access file,...
2
by: kathyk | last post by:
Hi All, I am using Access 2003. I have a function that I have been using to log on to linked tables using the system ODBC and it has been working great. Now I want to do the same thing using a...
0
by: maitrepoy | last post by:
Hello I have to create a small addin which works on Powerpoint, Word, Outlook, and Excel on Office 2000, XP, and 2003. This addin consists in adding 2 new Buttons in the "File" Menu of office....
0
by: maitrepoy | last post by:
hello I have to create a small addin which works on Powerpoint, Word, Outlook, and Excel on Office 2000, XP, and 2003. This addin consists in adding 2 new Buttons in the "File" Menu of office....
3
by: beliavsky | last post by:
I want to write a function that writes to an output file if specified and otherwise to standard output. How can I connect a file object to standard output in the code below? I could use an if...
3
by: enjoylife27 | last post by:
Hi there, I am using Perl 5.8 with Apache 2.2 on Win XP SP2, all configured and working fine. I am able to run perl programs from command prompt. I am also able to call CGI scripts from HTML pages...
4
by: gopiinamadar | last post by:
hi i want to connect a jsp file with oracle9i server. initially i used MS Access with jsp and i will copy all jsp and html pages in webapp/root files and run apache tomacat5.5, it works fine.. ...
1
by: mabubakarpk | last post by:
Hello every body ! I am using Access 97 and want to connect the tables of .mde file from vb6.0 as we connect .mdb file ( through DSN or OLEDB) . ...
5
Luigi
by: Luigi | last post by:
I use Access 2003 on Windows XP OS. I made an Access application with many linked table (essentialy txt file but also table of other mdb files); how can I move my principal mdb file and its relavant...
11
by: Mathanan | last post by:
<?php include("connect.php"); include("dbaselevel.php"); session_start(); $username = $_POST; $password = $_POST;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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.