Jump to content

[SOLVED] How To Write It Correctly


marukochan

Recommended Posts

Please help me.

 

I want to display the value of a query in a text box of a form. How do I write it?

 

The query

$query = mysql_query("SELECT * FROM project WHERE project_id = '$project_id'");

 

Extract the value

while($row=mysql_fetch_array($query)){

 

To display, I wrote ( a part of it)

<tr>

    <td>Location</td>

<td>:</td>

    <td><input type="text" name="location" value="<? echo $row['project_loc'] ?>"></td>

  </tr>

 

But it didn't work. I'm not exactly sure how to write php within html codes.

 

Please help.

Link to comment
https://forums.phpfreaks.com/topic/41203-solved-how-to-write-it-correctly/
Share on other sites

Do it like this :

$query = "SELECT * FROM project where project_id = '$project_id' ";
$result = mysql_query($query) or die(mysql_error());
$project_loc=$row->Project_loc;
while($row=mysql_fetch_array($query)){

 

Echo it like this:

<td><input type="text" name="location" value="<?php echo $project-loc ?>"></td>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.