Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hello,
I am making a website which makes use of PHP and MySQL and have run into a problem. I use the script below to get information from a database, and between each piece of information (".$row[line_one].") I want to put a line of HTML code, also from the database (".$row[line_two]."). The problem is that I don't want this bit of code after the last piece of information, so I'm wondering if there is a way to get something like the following to display:Code: Select all
<p>".$row[line_one]."</p>
<p>".$row[line_two]."</p>
<p>".$row[line_one]."</p>
<p>".$row[line_two]."</p>
<p>".$row[line_one]."</p>
<p>".$row[line_two]."</p>
<p>".$row[line_one]."</p>Here is the script I'm using:
--------------------
Code: Select all
<?php
...
mysql_connect($host,$username,$password) or die("Unable to connect to database");
@mysql_select_db("$database") or die ("Unable to select database $database");
$sqlquery = "SELECT * FROM $table";
$result = mysql_query($sqlquery);
while ($row = mysql_fetch_array($result)) {
echo "
<p>".$row[line_one]."</p>
<p>".$row[line_two]."</p>
";
}
if (mysql_num_rows($result)<1) {
echo "No Results!";
}
mysql_free_result($result);
?>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]