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. ;)

Link to comment
Share on other sites

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...

;)

Link to comment
Share on other sites

// 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?

Link to comment
Share on other sites

// 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 =)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.