Jump to content

new line while in WHILE loop


illuz1on

Recommended Posts

Okay, if $row is your result from mysql_query, than you could do this:

 

$result= mysql_query(your_query_string_here);

while ($row = mysql_fetch_assoc($result)) {
    echo $row['id'] . ' ' .$row['title'] .'<br>';
}

 

- id and title are field from your db table.

- < br > (without spaces) is new line in HTML

 

I hope this was what you asked us for. ;)

Well independent. If you want use form, than make form fields. But if you want use link than you can make like this:

 

$result= mysql_query(your_query_string_here);

while ($row = mysql_fetch_assoc($result)) {
    echo "${row['id']} ${row['title']} <a href='delete.php?id=${row['id']}'>Delete</a>";
}

 

In delete.php use $id =$_GET['id'] so you'll get id from link. But, be careful and check if user has been logged or not because somebody could use it to delte more than you want. Also I'm always making some checking to exclude possibility of error (first step would be to check if ID is numeric), etc...

;)

// Short vars

 

$id = $record['id'];

$title = $record['title'];

 

echo "$id. $title";

}

?>

 

This is just a snippet of code how do I make the echo line put each entry on a new line WHILE being in a while loop?

 

Thanks alot

 

what the hell are you talking about?

// Short vars

 

$id = $record['id'];

$title = $record['title'];

 

echo "$id. $title";

}

?>

 

This is just a snippet of code how do I make the echo line put each entry on a new line WHILE being in a while loop?

 

Thanks alot

 

what the hell are you talking about?

 

What the hell are you talking about? lol I think he made is case very clear, and obviously so as he got his questioned answer by 2 people =)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.