Jump to content


Photo

Content on the same page of the query


  • Please log in to reply
6 replies to this topic

#1 jofftan

jofftan
  • Members
  • Pip
  • Newbie
  • 4 posts
  • LocationMontreal

Posted 04 September 2006 - 03:33 AM

Hi, I'm looking for a way to choose data content from a dropdown menu, linked to a MySQL DB, and echo it on that same page.
The problem is when you get to that page for the first time I need to display the first entry of the data by default.

Now I have it but with two php files, I want this on the same page.

The way it is right now is

Page 1 ;
	<?php
			 
						$c = mysql_connect ($host,$usager,$Mpasse);
						mysql_select_db ('db', $c);
							
							if (!$c) {
							  die('Impossible de se connecter : ' .  error_reporting(E_ALL));
							}
													   
							$req = "SELECT * FROM Team";
							$resultat = mysql_query($req);
							
							echo '<ul id="subnavlist">';
								   
							while ($record = mysql_fetch_assoc($resultat)) {
			
								echo '<li id="subactive"><a href="corpoTeam.php?id_team='.$record["id_team"].'" id="current">'.$record["Titre"].'</a></li>';								
			 
							 }
			     		echo "</li>";
			?>

Page 2;
	<?php
			
							$_POST['id_team'];
			    			include 'connexion.php';
			
						$c = mysql_connect ($host,$usager,$Mpasse);
						mysql_select_db ('db', $c);
							
							if (!$c) {
							  die('Impossible de se connecter : ' . mysql_error());
							}
													   
							$req = "SELECT * FROM Team";
							$resultat = mysql_query($req);
							
							echo '<ul id="subnavlist">';
								   
							while ($record = mysql_fetch_assoc($resultat)) {
			
								echo '<li id="subactive"><a href="corpoTeam.php?id_team='.$record["id_team"].'" id="current">'.$record["Titre"].'</a></li>';								
			 
							 }
			     		echo "</li>";
			?>
					</li>
				</ul>

			</div>
			<div>
			<?php
          	 ini_set('display_errors', 1);
			error_reporting(E_ALL);
			
            		$req = "SELECT * FROM Team WHERE id_team = ".$id_team;
//            		            		$resultat = mysql_query ("SELECT Titre, description, name FROM Team WHERE id_team = '".urldecode($_GET['id_team'])."'");
                    $resultat = mysql_query($req);
                    $row=mysql_fetch_array($resultat);
			
			
                    $name = $row['name'];
                    $Titre = $row['Titre'];
                    $description = nl2br($row['description']);
                    
                    echo "<br>";
                    echo "<br>";               
                    echo '<h4>';
                    echo $name;
                    echo '<br>';
                    echo $Titre;
                    echo '</h4>';
                    echo '<p>';
                    echo $description;
                    echo '</p>';
                    	
			?>

Thank you

#2 marker5a

marker5a
  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts

Posted 04 September 2006 - 03:43 AM

It sounds like to me you are talking about implementing Javascript... but your question is not quite to clear.  COuld explain in clearer terms what you want...

Thanks

#3 jofftan

jofftan
  • Members
  • Pip
  • Newbie
  • 4 posts
  • LocationMontreal

Posted 04 September 2006 - 03:50 AM

Here's the link
http://www.virochemp...a.com/corpo.php

When you get to this page I'm echoing the first entry of the DB.
If you select another entry from the dropdown it call a second page.

I want all that operation on a single page.

I don't know if it's possible ?

#4 marker5a

marker5a
  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts

Posted 04 September 2006 - 03:53 AM

Yea, I understand what you are saying now... instead of these links on the left changing the page  (corpo_mission.php, corpo_history.php, etc...) you want to only change the text.

This cannot all be done with PHP.  You will need to change the hyperlinks to call a javscript function that changes the text in that box.  However, within this Javascript function you create, you will need to use PHP to pull the data from the DB.

I cannot help you easily with the javascript aspect... I would post this in the Javascript help forum.

#5 jofftan

jofftan
  • Members
  • Pip
  • Newbie
  • 4 posts
  • LocationMontreal

Posted 04 September 2006 - 04:01 AM

No I'm sorry I wasn't clear enough.
The links are in the dropdown of team members in the middle of the page.

#6 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 04 September 2006 - 04:17 AM

if you are asking to have a dropdown populated by entries in your db, and info changing on your page, like say, info in another dropdown, when you select a different dropdown value, before you have to go and click submit, then you are going to need a javascript method called AJAX. 

go to ajaxfreaks.com or google it.
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#7 jofftan

jofftan
  • Members
  • Pip
  • Newbie
  • 4 posts
  • LocationMontreal

Posted 04 September 2006 - 04:58 AM

Not exactly.

Ok now it's calling the same page within the link so it work I don't know if it's secure but it work.

while ($record = mysql_fetch_assoc($resultat)) {
			
								echo '<li id="subactive"><a href="corpo.php?id_team='.$record["id_team"].'" id="current">'.$record["Titre"].'</a></li>';								
			 
							 }

But now I got this error to fix

Notice: Undefined variable: id_team in /var/www/vhosts/virochempharma.com/httpdocs/corpo.php on line 106

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/vhosts/virochempharma.com/httpdocs/corpo.php on line 109






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users