If I have a page with something like:
<input type="text" name="f_name" value="First">
How do I pull the name out with PHP? Is there a way to do it like it's done in javascript?
<javascript>
firstName=form.f_name.value;
</javascript>
I know you can set up the value $f_name, but I will tell you why I have the prob.....
for ($i=0; $i < $matches; $i++)
{
$row = mysql_fetch_array($search_row);
echo "<tr>\n<input type=\"hidden\" name=\"id\" value=\"".$row["id"]."\">\n";
echo "<td align=\"center\">".($i+1)."</td>\n<td><span class=\"in\">";
echo $row["u_name"];
echo "</span></td>\n<td><span class=\"in\">";
echo $row["f_name"];
echo "</span></td>\n<td><span class=\"in\">";
echo $row["l_name"];
echo "</span></td>\n<td><span class=\"in\">";
echo $row["dept"];
echo "</span></td>\n";
echo "<td align=\"center\">\n";
echo "<input type=\"submit\" value=\"Del\" name=\"del\">".$row["id"]."";
//echo "<input type=\"button\" value=\"Mod\"></td></tr>\n"; //modify button. Will get to work after Del works
}
echo "</table>\n";
If you look above you will see that the it is a dynamically created table based on $matches. Here, echo "<tr>\n<input type=\"hidden\" name=\"id\" value=\"".$row["id"]."\">\n"; I want to get the value from
value=\"".$row["id"]."\" because I am looking to be able to delete that username if it is no longer needed.
Maybe someone could walk me through this? I am still really new but I am determined to make this thing work.....
Still new to this, this one could be simple
Moderator: General Moderators
maybe this example helps you
Code: Select all
<html><body>
<fieldset><legend>example output of transmitted request-data</legend>
<?php
echo '<pre>'; print_r($_POST); echo '</pre>';
if (isset($_POSTї'i1']))
echo 'i1-value is: ', $_POSTї'i1'] , '<br>';
if (isset($_POSTї'i2']))
echo 'i2-value is: ', $_POSTї'i2'] , '<br>';
if (isset($_POSTї'dropdown']))
echo 'radiobutton-value: ', $_POSTї'dropdown'], '<br/>';
echo 'dropdown-value: ', isset($_POSTї'radiobutton']) ? $_POSTї'radiobutton'] : '--undefined--', '<br/>';
if (isset($_POSTї'checkarr']))
{
echo '<table border="1"><tr><th>values in the array <i>checkarr</i></th></tr>';
foreach($_POSTї'checkarr'] as $value)
echo '<tr><td>', $value, '</td></tr>';
echo '</table>';
}
?>
</fieldset>
<form method="POST">
<input type="hidden" name="invisible" value="but still there" />
<hr/> text inputs <br/>
i1: <input type="text" name="i1" value="default" /> <br/>
i2: <input type="text" name="i2" value="default, too" /> <br/>
<hr/> selection field <br/>
<select name="dropdown">
<option value="first">1</option>
<option value="second">2</option>
<option value="third" selected="true">3</option>
<option value="fourth">4</option>
</select>
<hr/> radio buttons <br/>
A: <input type="radio" name="radiobutton" value="a"/> <br/>
B: <input type="radio" name="radiobutton" value="b" checked="true"/> <br/>
C: <input type="radio" name="radiobutton" value="c"/> <br/>
D: <input type="radio" name="radiobutton" value="d"/>
<hr/> checkboxes <br/>
A: <input type="checkbox" name="checkarrї]" value="a" checked="true"/> <br/>
B: <input type="checkbox" name="checkarrї]" value="b" checked="true"/> <br/>
C: <input type="checkbox" name="checkarrї]" value="c"/> <br/>
D: <input type="checkbox" name="checkarrї]" value="d"/> <br/>
<input type="submit" />
</form>
</body></html>