Page 1 of 1

displaying info in rows

Posted: Wed May 19, 2004 9:18 pm
by marker5a
Ok
I am writing a script that basically takes data from a table, specifically names of different users, and displays them as links. I have it setup, but when it displays the links, they are right after eachother. http://www.marker5a.com/dbmenu.php I would like to set it up, so that after each link it goes to the next line and puts the next link. My script is

<?php
$db = mysql_connect("*", "*", "*");
mysql_select_db("profile",$db);

$sql="SELECT FirstName,LastName,contact_id FROM `names`";
$result=mysql_query($sql,$db);
while($row=mysql_fetch_array($result))
{
$id = $row["contact_id"];
$FirstName = $row["FirstName"];
$LastName = $row["LastName"];
echo "<a href=http://www.marker5a.com/db.php?id=$id>$FirstName $LastName</a>";
}
?>


PLease help me

Thanks you
Chris

Posted: Wed May 19, 2004 9:27 pm
by d3ad1ysp0rk

Code: Select all

<?php 
$db = mysql_connect("*", "*", "*"); 
mysql_select_db("profile",$db); 

$sql="SELECT FirstName,LastName,contact_id FROM `names`"; 
$result=mysql_query($sql,$db); 
while($row=mysql_fetch_array($result)) 
{ 
$id = $row["contact_id"]; 
$FirstName = $row["FirstName"]; 
$LastName = $row["LastName"]; 
echo "<a href=http://www.marker5a.com/db.php?id=$id>$FirstName $LastName</a><br />"; 
} 
?>

Posted: Wed May 19, 2004 9:29 pm
by marker5a
Wow, that was easy. Thanks so much, I appreciate it.

Chris

Posted: Wed May 19, 2004 9:37 pm
by d3ad1ysp0rk
no problem :)

Posted: Thu May 20, 2004 10:16 pm
by marker5a
ok
Ive got one more problem. I am trying to display images based on the $id number.

echo "<img src=www.marker5a.com/database/images/$id.jpg>:;

For some reason, it isnt displaying the image though. What should i do. Thanks in advance

Chris

Posted: Thu May 20, 2004 10:18 pm
by marker5a

Posted: Thu May 20, 2004 10:26 pm
by tim
echo '<img src=http://domain.com/images/'.$id .'.jpg';

?

Posted: Thu May 20, 2004 10:30 pm
by marker5a
tried it, didnt work. But thank you

Posted: Thu May 20, 2004 10:46 pm
by tim
well what do they display?

syntax error? what

Posted: Thu May 20, 2004 10:58 pm
by tim

Code: Select all

<?php
$tim= "tim";
echo '<img src=http://theoryofevil.com/faces/' .$tim . '.jpg>';
?>
works

my first example was missed the >