displaying info in rows

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
marker5a
Forum Commoner
Posts: 29
Joined: Wed May 19, 2004 9:18 pm

displaying info in rows

Post 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
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post 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 />"; 
} 
?>
marker5a
Forum Commoner
Posts: 29
Joined: Wed May 19, 2004 9:18 pm

Post by marker5a »

Wow, that was easy. Thanks so much, I appreciate it.

Chris
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

no problem :)
marker5a
Forum Commoner
Posts: 29
Joined: Wed May 19, 2004 9:18 pm

Post 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
marker5a
Forum Commoner
Posts: 29
Joined: Wed May 19, 2004 9:18 pm

Post by marker5a »

User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

echo '<img src=http://domain.com/images/'.$id .'.jpg';

?
marker5a
Forum Commoner
Posts: 29
Joined: Wed May 19, 2004 9:18 pm

Post by marker5a »

tried it, didnt work. But thank you
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

well what do they display?

syntax error? what
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

Code: Select all

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

my first example was missed the >
Post Reply