Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML and PHP form.. please help

Status
Not open for further replies.

monasa

IS-IT--Management
Jun 27, 2004
41
0
0
CA
In php I have a variable which called $room
I want to display the containt of this variable as a default valut of input box in HTML form.
Like :

<input type="text" value=$room name="room">

but like this this does not work.

please help
 
try this:

Code:
 <input type="text" value="<? echo $room; ?>" name="room">


B
 
I would not get in the habit of switching back and forth between throughput mode and interpreted mode. It hurst the performance of your script.

I would do:

Code:
<?php
print '<input type="text" value="' . $room . '" name="room">';
?>


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
thats nearly the answer i'm also looking for.
i want to be able to populate a dropdown list box with the results of an SQL select string?
how would i amend the above code for this?

free, anonymous advice provided by the whole world
 
it's the same deal!

outside of the recordset loop (before):
Code:
echo "<select name=\"select_name\">";

In the recordset loop:
Code:
if ($selected == {$row['value']})
  {
    echo "<option value=\"{$row['value']}\" selected=\"selected\">{$row['title']}</option>\n";
  }
else
  {
    echo "<option value=\"{$row['value']}\">{$row['title']}</option>\n";
  }

Outside of the recordset loop:
Code:
</select>

Olav Alexander Mjelde
Admin & Webmaster
 
for a minute there i was like "woah" - then i remembered backslash is the escape character in php right?

i'll give it a whirl. thanks.


free, anonymous advice provided by the whole world
 
np..
btw.. the if ($selected = ..

that variable name, has to be the same as the select name! (if you submit to self, or save in sessions, you can make it keep values that you submitted.. (eg. on go-back or if some values are keeping the submit back, due to validation rules)

Olav Alexander Mjelde
Admin & Webmaster
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top