Re: forms and mysql
| From: | David Robley | Date: | Tue, 02 Dec 2003 12:56:14 +0000 |
| Subject: | Re: forms and mysql | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-171568@lists.php.net to get a copy of this message | ||
In article <20031202120023.18900.qmail@pb1.pair.com>,
neretlis@westnet.com.au says...
> Hi i am very new to PHP so need some help !
>
> i have a form which allows the user to put in 2 team names and then displays
> them, at the moment it displays them side by side but i need to insert V
> (versus) in the middle--how can i do that.
> I am guessing it goes in the lines of the code below somewhere, This code
> originally displayed someones input for --first name,last name and address
> so i have adapted it. Is there anyway to have the 'address' field display a
> set value as in a V , at the moment i have removed that part but the table
> field is still there, i have just hidden the form input.
>
>
> $result = mysql_query("SELECT * FROM teams",$db);
>
> while ($myrow = mysql_fetch_array($result)) {
>
> printf("<a href=\"%s?id=%s\">%s %s</a> \n", $PHP_SELF,
> $myrow["id"],
> $myrow["teama"],$myrow["teamb"]);
I'm sure that printf and friends must be most confusing to those who don't
come from a C background :-)
I think something like this might work, and be a bit more comprehensible
to a neophyte.
$result = mysql_query("SELECT * FROM teams",$db);
while ($myrow = mysql_fetch_array($result)) {
extract($myrow); // allows you to access fields as $id, $teama etc
// printf("<a href=\"%s?id=%s\">%s %s</a> \n", $PHP_SELF,
$myrow["id"],
// $myrow["teama"],$myrow["teamb"]);
echo '<A
HREF="'.$_SERVER{'PHP_SELF'}.'?id='.$id.'">' .
"\n";
echo "$teama V $teamb</A>\n";
}
--
Quod subigo farinam
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet?