Get and Post

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bla5e
Forum Contributor
Posts: 234
Joined: Tue May 25, 2004 4:28 pm

Get and Post

Post by bla5e »

Code: Select all

switch ($id) {
						case '$_GETї"id"]':
						error_reporting(E_ALL);  

						$dbh=mysql_connect ("localhost", "***", "***") or die ('I cannot connect to the database because: ' . mysql_error()); 
						mysql_select_db ("steve_onepurpose"); 
						$sql = "SELECT * FROM `roster` WHERE `id` = " . $_GETї'id'] ." ";
						echo mysql_error();
						$result = mysql_query($sql, $dbh);
						echo mysql_error();
						while ($data = mysql_fetch_assoc($result)) {
					  echo ("<DIV ALIGN="CENTER" style="width: 440; height: 159">");
					  echo ("<font face="Verdana" size="1">");
					  echo ("<b>Name</b>");
					  echo $data&#1111;"name"];
					  echo ("<br>");
                      echo ("<b>Alias </b>");
					  echo $data&#1111;"alias"];
                      echo ("<b>Position</b> ");
					  echo $data&#1111;"member"];
					  echo ("<br>");
                      echo ("<b>Age </b>");
					  echo $data&#1111;"age"];
					  echo ("<br>");
                      echo ("<b>E-mail</b>"); 
					  echo $data&#1111;"email"];
					  echo ("<br>");
                      echo ("<b>Location </b>");
					  echo $data&#1111;"location"];
					  echo ("<br>");
                      echo ("<b>Favorite map </b>");
					  echo $data&#1111;"map"];
					  echo ("<br>");
                      echo ("<b>Favorite gun</b>");
					  echo $data&#1111;"gun"];
					  echo ("<br>");
                      echo ("<b>Quote</b> "");
					  echo $data&#1111;"quote"];
					  echo (""<br>");
                      echo ("<b>sensitivity </b>");
					  echo $data&#1111;"sensitivity"];
					  echo ("<br>");
                      echo ("<b>Resolution </b>");
					  echo $data&#1111;"resolution"];
					  echo ("</font>");
					  echo ("</DIV>");
					  &#125;
						break;
What im trying to do:

index.php?id=<number>
The <number> will display that <number>'s info


feyd | removed username/password
User avatar
Trenchant
Forum Contributor
Posts: 291
Joined: Mon Nov 29, 2004 6:04 pm
Location: Web Dummy IS

Post by Trenchant »

to get ?id=$variable from somepage.php?id=8 you have to use $_REQUEST[''];

Code: Select all

<?php
$id = $_REQUEST&#1111;'id'];
if (!$id) &#123;
  echo "There was no posted.";
&#125;else&#123;
  echo "ID requested:".$id.".";
&#125;
?>
crc
Forum Newbie
Posts: 5
Joined: Thu Jan 13, 2005 10:31 pm

Post by crc »

Rule of thumb*

Don't put "real" database information when posting to boards (ie. database name, user, password).

Be more specific as to what you need. In this post case, we have to first figure out what exactly you're trying to do (specifically), then go through "all" your code.

If you could, tell us specifically what you are trying to do and what error messages you're getting, or what output you're getting.

, crc
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

make sure to avoid the undefined variable notice/warnings...

Code: Select all

$id = (isset($_REQUEST&#1111;'id']) ? $_REQUEST&#1111;'id'] : false);

if (!$id) &#123;
  echo "There was no posted.";
&#125;else&#123;
  echo "ID requested:".$id.".";
&#125;
bla5e
Forum Contributor
Posts: 234
Joined: Tue May 25, 2004 4:28 pm

Post by bla5e »

can someone post the whole script cuz im not really understanding what u guys are saying..

Heres my original code:

Code: Select all

<?php
switch($s) &#123;
case 'roster':
					error_reporting(E_ALL);  

					$dbh=mysql_connect ("localhost", "<USN>", "<PW>") or die ('I cannot connect to the database because: ' . mysql_error()); 
					mysql_select_db ("steve_onepurpose"); 
					$sql = "SE+LECT * FROM roster";
					echo mysql_error();
					$result = mysql_query($sql, $dbh);
					echo mysql_error();

					echo ("<TABLE WIDTH="403" BORDER="0" CELLSPACING="0" CELLPADDING="0">");
					echo ("<tr>");
					echo ("<td width="67" height="10"><b><font face="Verdana" size="1">Alias</font></b></td>");
					echo ("<td width="120" height="10"><b><font size="1" face="Verdana">Name</font></b></td>");
					echo ("<td width="73" height="10"><b><font size="1" face="Verdana">Position</font></b></td>");
					echo ("</tr>");
					while ($data = mysql_fetch_assoc($result)) &#123;
					echo ("<tr>");   
					echo ("<td width="67" height="15" bgcolor="#737C83"><font face="Verdana" size="1">");
					echo $data&#1111;"alias"];
					echo ("</font></td>");
					echo ("<td width="120" height="15" bgcolor="#737C83"><font size="1" face="Verdana">");
					echo $data&#1111;"name"];
					echo ("</font></td>");
					echo ("<td width="73" height="15" bgcolor="#737C83"><font size="1" face="Verdana">");
					echo $data&#1111;"position"];
					echo ("</font></td>");
					echo ("</tr>");
					echo mysql_error();
					&#125;
					echo ("</TABLE>");
					echo ("<br><br>");
						switch ($id) &#123;
						case '$_GET&#1111;"id"]':
						error_reporting(E_ALL);  

						$dbh=mysql_connect ("localhost", "<USN>", "<PW>") or die ('I cannot connect to the database because: ' . mysql_error()); 
						mysql_select_db ("steve_onepurpose"); 
						$sql = "SEL+ECT * FROM `roster` WHERE `id` = " . $_GET&#1111;'id'] ." ";
						echo mysql_error();
						$result = mysql_query($sql, $dbh);
						echo mysql_error();
						while ($data = mysql_fetch_assoc($result)) &#123;
					  echo ("<DIV ALIGN="CENTER" style="width: 440; height: 159">");
					  echo ("<font face="Verdana" size="1">");
					  echo ("<b>Name</b>");
					  echo $data&#1111;"name"];
					  echo ("<br>");
                      echo ("<b>Alias </b>");
					  echo $data&#1111;"alias"];
                      echo ("<b>Position</b> ");
					  echo $data&#1111;"member"];
					  echo ("<br>");
                      echo ("<b>Age </b>");
					  echo $data&#1111;"age"];
					  echo ("<br>");
                      echo ("<b>E-mail</b>"); 
					  echo $data&#1111;"email"];
					  echo ("<br>");
                      echo ("<b>Location </b>");
					  echo $data&#1111;"location"];
					  echo ("<br>");
                      echo ("<b>Favorite map </b>");
					  echo $data&#1111;"map"];
					  echo ("<br>");
                      echo ("<b>Favorite gun</b>");
					  echo $data&#1111;"gun"];
					  echo ("<br>");
                      echo ("<b>Quote</b> "");
					  echo $data&#1111;"quote"];
					  echo (""<br>");
                      echo ("<b>sensitivity </b>");
					  echo $data&#1111;"sensitivity"];
					  echo ("<br>");
                      echo ("<b>Resolution </b>");
					  echo $data&#1111;"resolution"];
					  echo ("</font>");
					  echo ("</DIV>");
					  &#125;
						break;
						&#125;
					break;
?>
it works like this

index.php?s=roster&id=<number>

the <number> will display that persons extended info
Post Reply