thanks to bpat1434 i was able to figure out dynamic links, and now i am trying to expand on them.
i have a mysql database with contact information. i am setting up a form where people can select a name from a drop down list, which will take them to a form displaying that persons information. i've been able to get this to about 90% functionality, but am struggling with a few things. here's the code for the drop down page:
<?
$username="name";
$password="pwd";
$database="db";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM addressbook ORDER BY efgname ASC";
$result=mysql_query($query);
$num=mysql_num_rows($result);
mysql_close();
?>
// Tables and some HTML
<?
$i=0;
while ($i < $num) {
$id = mysql_result($result, $i, 'id');
$efgname=mysql_result($result,$i,"efgname");
?>
<option value="name"><? echo $efgname; ?></option>
<?
$i++;
}
?>
so this seems to work just fine. here is the code on the form that displays the information (update.php):
<input type="text" name="name1" value="<?php
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$id = (int)$_GET['id'];
$query = "SELECT name1 FROM `addressbook` WHERE id='".mysql_real_escape_string($id)."' LIMIT 0,1";
$result = mysql_query($query);
$name1 = mysql_result($result, 0, 0);
echo $name1;
mysql_close();
?>
this also works fine. i'm sure there's an easier way to do this using mysql_fetch_array, but i haven't been able to get that far yet (any help, as always, is appreciated). but the real problem i am facing is in the click to view link, which is as follows:
<a href="update.php?id=<? echo $id; ?>Click to view</a>
regardless of which selection you highlight, you are always taken to the first record. i was able to add a loop after the click to view which solved this problem, but the link is repeated for however many records are in the database. any ideas?
thanks!