|
Posted by The Natural Philosopher on 11/14/07 11:50
Lloyd Harold wrote:
> I'm very new to PHP and attempting to put together a simple script for
> retrieving MySQL data of personal records.
>
> The MySQL table I'm using consists of:
>
> 0: id
> 1: name
> 2: location (an integer relating to a separate table of locations).
> 3: details
>
> I want the script to list results where, for example, name has a
> location of 4.
>
$query="select * from mytable where location ='4'";
$result=mysql_query($query);
> Each result should be displayed in it's own paragraph.
>
if ($result && ($rows=myql_numrows($result) >0))
{
> Each result should be within a link to open a new page (details.php ?)
> that will retrieve the details for that name.
>
for($i=0;$;<$rows;$i++)
{
> Ideally, but not essentially, the new page should contain a link back to
> the previous results.
>
$last_id=$__GET['id'];
$var1=mysql_result($result,'id); // and any other variables you
want.
printf("<p><A HREF=Mycode.php?id=%d>id=%d,</A>\r\n",
$last_id,$var1);
}
}
> I've managed to cobble together something displays the initial results
> but, despite trawling Google, haven't managed to suss out the rest.
> (It's ugly and insecure so probably best to start from scratch.)
>
> Any pointers gratefully received.
>
> LH
>
Navigation:
[Reply to this message]
|