473,804 Members | 2,280 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

multiple pages linked by hyperlink mysql query

55 New Member
Hi All,
I have a mysql database and 3 pages which queries and returns the data.
1st page(main.html) is just a form in html which takes query from the user and is connected to "form action="index.p hp"".
2nd page(index.php) has the mysql queries and gives a brief information(one line) about the user query. Now the index.php has a hyperlink to the third page(summary.ph p) which gives detailed information about the user query.
3rd page(summary.ph p) has detailed mysql statements.
all the three pages have
Expand|Select|Wrap|Line Numbers
  1. session_start();
  2. $_SESSION['field'] = $_POST['keyword'];
  3. echo session_id();
and the session ids are identical for the pages.

Problem: when I provides the query term in the text box of the html page(main.html) and click on submit button, it directs me to the index.php page which provides me the one line information.... .till here it goes fine, but when I click the hyperlink on the index.php page it does takes me to the summary.php page but there is information fetched from the mysql database, means the tables are empy.
It seems that its not fetching the data.

Any help.

thanks
Sep 16 '07 #1
8 2344
pbmods
5,821 Recognized Expert Expert
Heya, Kumar.

Sounds like you might be hitting a MySQL error.

Try adding this line after relevant queries:
Expand|Select|Wrap|Line Numbers
  1. echo mysql_error();
  2.  
Sep 16 '07 #2
kumarboston
55 New Member
Hi
thanks for the reply but I already inserted the error statement after each mysql statement like this:
$result2 = mysql_query($qu ery2) or die('Query failed: ' . mysql_error());

do i need to again post the request from index.php to summary.php??

kumar
Sep 16 '07 #3
pbmods
5,821 Recognized Expert Expert
Heya, Kumar.

$_POST will be empty unless you are submitting a form (and even then, you have to set method="post").

Did you mean to use $_GET['keyword'] instead?
Sep 17 '07 #4
kumarboston
55 New Member
hi pdmods...

sorry for the late reply...was busy with something...
yes , can I use the $_GET to retrieve the records from the third page...

if its possible(for guidance and suggestions) then I can send u my scripts through e-mail ....

thanks
kumar
Sep 18 '07 #5
kumarboston
55 New Member
Hi Pbmods,

this is my url string on the page index.php which collects the id and hyperlinks it to the summary.php.
Expand|Select|Wrap|Line Numbers
  1. while ($line1 = mysql_fetch_array($result1, MYSQL_ASSOC))
  2.         {
  3.             echo "<tr>";
  4.             echo "<td><center> <a href=\"summary.php?ID=".$line1['gene_id']."\">".$line1['gene_id']."</a></center></td>";    
  5.             echo "</tr>\n";
  6.         }
  7.  
  8.  
and now the summary.php has the following code
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. print_r($_GET);
  3.  
  4. $link = @mysql_connect('localhost','root','xxxxxxxx');
  5.     if(!$link)
  6.     {
  7.         echo("<p>Unable to connect to the database server at this time.</p>");
  8.         exit();
  9.     }
  10.     else
  11.     {
  12.         //echo "Connected successfully\n";
  13.     }
  14.  
  15.     if(! @mysql_select_db('biology'))
  16.     {
  17.         echo("<p>Unable to locate the biology " .
  18.                  "database at this time.</p>");
  19.         exit();
  20.     }
  21.  
  22.  
  23.         $classi="select classification.c_group,classification.c_family,classification.c_subfamily from gene, classification where gene.gene_id=classification.gene_id and gene.gene_id='$keyword'";
  24.         $res_classi=mysql_query($classi) or die('Query failed: ' . mysql_error());
  25.         echo "<div align=\"center\"> <b>REPORT</b><br><br></div>";
  26.         echo "<table align=\"center\" border=\"1\" width=\"69%\" bgcolor=\"#FFFFFF\" cellspacing=\"1\" cellpadding=\"1\">\n";
  27.         while ($res_line = mysql_fetch_array($res_classi, MYSQL_ASSOC))
  28.         {
  29.             echo "<tr>";
  30.                 echo "<td width=\"30%\" bgcolor=\"#CCFF66\"><left><b>Group</b></left></td>";
  31.                 echo "<td><center>{$res_line['c_group']}</td>";
  32.                 echo "</tr>";
  33.             echo "<tr>";
  34.                 echo "<td width=\"30%\" bgcolor=\"#CCFF66\"><left><b>Family</b></left></td>";
  35.                 echo "<td><center>{$res_line['c_family']}</td>";
  36.                 echo "</tr>";
  37.             }
  38. echo "</table>";
  39.  
when i clicked on the hyperlink from index.php it echoed the "print_r($_GET) " = Array ( [ID] => 25 ) that means it is getting the gene id from the index.php but I am not able to pass the Array value to the below $keyword variable.
when I tried to assign this value of Array to the variable no sql wuery was executed and the tables were empty.
I am first time writing the code in php and i might be missing some very important points.
any suggestions
kumar
Sep 18 '07 #6
kumarboston
55 New Member
Hey pbmods,
I think I have solved the problem, what I did just added a foreach loop for the $_GET,
Expand|Select|Wrap|Line Numbers
  1. foreach ( $_GET as $keyword => $value ) {
  2. $keyword = $value;
  3. }
  4.  
and the value in $keyword is being passed to the sql statements..... .well its working now, but is this the right way to access the value of the array in $_GET??

read around 150 posts on this forum to get it working and cleared some of my basics too.......
Site ROCKS !!!!!!!!!!!!

kumar
Sep 18 '07 #7
pbmods
5,821 Recognized Expert Expert
Heya, Kumar.

That will work. The idea though is to perform at least some kind of validation on your inputs before you use them.

Even something as simple as:
Expand|Select|Wrap|Line Numbers
  1. foreach( $_GET as $keyword => $value )
  2. {
  3.     $$keyword = mysql_real_escape_string($value, $dbConn);
  4. }
  5.  
where $dbConn is your MySQL connection resource.
Sep 18 '07 #8
kumarboston
55 New Member
Thanks for this valuable suggestion.

If i face any any other problems, then will mail u.

thanks
kumar
Sep 19 '07 #9

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

Similar topics

4
6778
by: Bob Hotschins | last post by:
I've joined several columns from several tables, and I would like to perform a relevance match against these multiple columns. It looks something like this: SELECT * FROM table1 LEFT JOIN column1 ON table2.column1 LEFT JOIN column 2 ON table3.column1 WHERE MATCH ( table2.column1, table3.column1)
4
16760
by: DG | last post by:
Hi, Can anyone advise how to execute multiple statements in a single query batch. For example- update customers set customer_name = 'Smith' where customer_name = 'Smyth'; select * from customers; I can execute each statement individually but get the 'you have an error in
19
3482
by: davidgordon | last post by:
Hi, I need some pointers/help on how to do the following if it possible: In my access db, I have the following: Tables: Products, Sub-Assembly, Product-Pack Table, Products
7
11722
by: Bob Sanderson | last post by:
I have a php page which contains the code: echo "<tr>"; echo "<th>$JobNumber</th>"; echo "<td>$Description</td>"; echo "<td>$NSN</td>"; echo "<td>$Manufacturer</td>"; echo "<td>$PartNumber</td>"; echo "</tr>";
9
2126
chumlyumly
by: chumlyumly | last post by:
Hello - Please help! I'm creating search pages using Dreamweaver 8, PHP, and MySQL database with Mac OS X. I think my code is good, but when I run my query, I come up with no data, even though I know there is data in the database that should be coming up. I'm searching two tables that are linked with a foreign key (member_id). The members table is the main table (where "member_id" is an auto increment key) , and the specialty_groups...
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'...
5
2912
by: mramsay | last post by:
HI, I'm having alot of problems trying to figure out how to create drop down links from a hyperlink on my homepage. I have a hyperlink called Programs (this is for a community centre) When the Programs hyperlink is selected I would like a drop down of link from my programs mysql table to be displayed. So far, it takes my mysql data and puts it as link but on it's own. I'm not sure how to put it under my Programs hyperlinks. Also...
1
1757
by: mramsay | last post by:
Hi there, I have a dynamic hyperlink Baseball. When the user select the hyperlink they are redirected to another page. After that I want to display information on the page from my linkstbl. The information I want to display is Baseball and some text I have entered in the database. I'm having a problem displaying the two fields for Baseball. The two field names are linkdescription and text. How do I get my sql query to pull out the...
4
3180
by: cjacks | last post by:
I have 2 tables linked by a common field. users ------ id ....more columns users_profiles -------------- users_id
0
9714
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9594
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10599
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
10346
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
10347
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
10090
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7635
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6863
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
5531
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...

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.