Page 1 of 1
Get and Post
Posted: Mon Jan 17, 2005 7:17 pm
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ї"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
Posted: Mon Jan 17, 2005 7:50 pm
by Trenchant
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.".";
}
?>
Posted: Mon Jan 17, 2005 7:52 pm
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
Posted: Mon Jan 17, 2005 8:24 pm
by feyd
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.".";
}
Posted: Mon Jan 17, 2005 9:13 pm
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) {
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