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
bla5e
Forum Contributor
Posts: 234 Joined: Tue May 25, 2004 4:28 pm
Post
by bla5e » Mon Jan 17, 2005 7:17 pm
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ї"name"];
echo ("<br>");
echo ("<b>Alias </b>");
echo $dataї"alias"];
echo ("<b>Position</b> ");
echo $dataї"member"];
echo ("<br>");
echo ("<b>Age </b>");
echo $dataї"age"];
echo ("<br>");
echo ("<b>E-mail</b>");
echo $dataї"email"];
echo ("<br>");
echo ("<b>Location </b>");
echo $dataї"location"];
echo ("<br>");
echo ("<b>Favorite map </b>");
echo $dataї"map"];
echo ("<br>");
echo ("<b>Favorite gun</b>");
echo $dataї"gun"];
echo ("<br>");
echo ("<b>Quote</b> "");
echo $dataї"quote"];
echo (""<br>");
echo ("<b>sensitivity </b>");
echo $dataї"sensitivity"];
echo ("<br>");
echo ("<b>Resolution </b>");
echo $dataї"resolution"];
echo ("</font>");
echo ("</DIV>");
}
break;
What im trying to do:
index.php?id=<number>
The <number> will display that <number>'s info
feyd | removed username/password
Trenchant
Forum Contributor
Posts: 291 Joined: Mon Nov 29, 2004 6:04 pm
Location: Web Dummy IS
Post
by Trenchant » Mon Jan 17, 2005 7:50 pm
to get ?id=$variable from somepage.php?
id=8 you have to use $_REQUEST[''];
Code: Select all
<?php
$id = $_REQUESTї'id'];
if (!$id) {
echo "There was no posted.";
}else{
echo "ID requested:".$id.".";
}
?>
crc
Forum Newbie
Posts: 5 Joined: Thu Jan 13, 2005 10:31 pm
Post
by crc » Mon Jan 17, 2005 7:52 pm
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
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Jan 17, 2005 8:24 pm
make sure to avoid the undefined variable notice/warnings...
Code: Select all
$id = (isset($_REQUESTї'id']) ? $_REQUESTї'id'] : false);
if (!$id) {
echo "There was no posted.";
}else{
echo "ID requested:".$id.".";
}
bla5e
Forum Contributor
Posts: 234 Joined: Tue May 25, 2004 4:28 pm
Post
by bla5e » Mon Jan 17, 2005 9:13 pm
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) {
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)) {
echo ("<tr>");
echo ("<td width="67" height="15" bgcolor="#737C83"><font face="Verdana" size="1">");
echo $dataї"alias"];
echo ("</font></td>");
echo ("<td width="120" height="15" bgcolor="#737C83"><font size="1" face="Verdana">");
echo $dataї"name"];
echo ("</font></td>");
echo ("<td width="73" height="15" bgcolor="#737C83"><font size="1" face="Verdana">");
echo $dataї"position"];
echo ("</font></td>");
echo ("</tr>");
echo mysql_error();
}
echo ("</TABLE>");
echo ("<br><br>");
switch ($id) {
case '$_GETї"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ї'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ї"name"];
echo ("<br>");
echo ("<b>Alias </b>");
echo $dataї"alias"];
echo ("<b>Position</b> ");
echo $dataї"member"];
echo ("<br>");
echo ("<b>Age </b>");
echo $dataї"age"];
echo ("<br>");
echo ("<b>E-mail</b>");
echo $dataї"email"];
echo ("<br>");
echo ("<b>Location </b>");
echo $dataї"location"];
echo ("<br>");
echo ("<b>Favorite map </b>");
echo $dataї"map"];
echo ("<br>");
echo ("<b>Favorite gun</b>");
echo $dataї"gun"];
echo ("<br>");
echo ("<b>Quote</b> "");
echo $dataї"quote"];
echo (""<br>");
echo ("<b>sensitivity </b>");
echo $dataї"sensitivity"];
echo ("<br>");
echo ("<b>Resolution </b>");
echo $dataї"resolution"];
echo ("</font>");
echo ("</DIV>");
}
break;
}
break;
?>
it works like this
index.php?s=roster&id=<number>
the <number> will display that persons extended info