return problem
Moderator: General Moderators
-
mrpaulfrank
- Forum Commoner
- Posts: 33
- Joined: Sun Jun 23, 2002 3:39 am
return problem
while($row_Recordset1 = mysql_fetch_assoc($Recordset1))
{
$image = $row_Recordset1['image'];
if($genre = "comedy")
{
echo "<A href=backs/$image.jpg><IMG SRC=images/$image.jpg></A>"."<br>\n".
"Title: ".$row_Recordset1['title']."<br>\n".
"Format: ".$row_Recordset1['format']."<br>\n".
"Price: ".$row_Recordset1['make']."<br>\n\n";
}
}
how can i get the results (one result being a whole loop existing of an image, title, format, and make) to be placed horizontally instead of vertically?
{
$image = $row_Recordset1['image'];
if($genre = "comedy")
{
echo "<A href=backs/$image.jpg><IMG SRC=images/$image.jpg></A>"."<br>\n".
"Title: ".$row_Recordset1['title']."<br>\n".
"Format: ".$row_Recordset1['format']."<br>\n".
"Price: ".$row_Recordset1['make']."<br>\n\n";
}
}
how can i get the results (one result being a whole loop existing of an image, title, format, and make) to be placed horizontally instead of vertically?
-
garymailer
- Forum Newbie
- Posts: 1
- Joined: Mon Jul 01, 2002 1:59 am
- Contact:
Mrpaulfrank
Code: Select all
I've simply taken out all the <br> and the newline characters (\n) tags and included one at then end
while($row_Recordset1 = mysql_fetch_assoc($Recordset1))
{
$image = $row_Recordset1ї'image'];
if($genre = "comedy")
{
echo "<A href=backs/$image.jpg><IMG SRC=images/$image.jpg></A>".
"Title: ".$row_Recordset1ї'title']."
"Format: ".$row_Recordset1ї'format']."
"Price: ".$row_Recordset1ї'make'].".
<br />";
}
}-
mrpaulfrank
- Forum Commoner
- Posts: 33
- Joined: Sun Jun 23, 2002 3:39 am
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
piece of cake
Code: Select all
echo "<table cellpadding="0" cellspacing="5"><tr>";
while($row_Recordset1 = mysql_fetch_assoc($Recordset1))
{
$image = $row_Recordset1ї'image'];
if($genre = "comedy")
{
echo "<td><table cellpadding="0" cellspacing="2"><tr><td>"
."<A href=backs/$image.jpg><IMG SRC=images/$image.jpg></A></td></tr>".
"<tr><td>Title: ".$row_Recordset1ї'title']."
"</td></tr><tr><td>Format: ".$row_Recordset1ї'format']."
"</td></tr><tr><td>Price: ".$row_Recordset1ї'make']."</td></tr></table></td>";
}
}
echo "</tr></table>";-
mrpaulfrank
- Forum Commoner
- Posts: 33
- Joined: Sun Jun 23, 2002 3:39 am
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
What the code should do is create a large table where on each iteration of the while loop a new cell is created and another table inserted into it containing a few rows with the information from the database, here's the code again, laid out differently and with a couple of parse errors removed:
Mac
Code: Select all
<?php
echo <<<END
<table cellpadding="0" cellspacing="5">
<tr>
END;
while($row_Recordset1 = mysql_fetch_assoc($Recordset1)) {
$image = $row_Recordset1ї'image'];
if ($genre == 'comedy') {
echo <<<END
<td>
<table cellpadding="0" cellspacing="2">
<tr>
<td><a href="backs/$image.jpg"><img src="images/$image.jpg"></a></td>
</tr>
<tr>
<td>Title: {$row_Recordset1ї'title']}</td>
</tr>
<tr>
<td>Format: {$row_Recordset1ї'format']}</td>
</tr>
<tr>
<td>Price: {$row_Recordset1ї'make']}</td>
</tr>
</table>
</td>
END;
}
}
echo <<<END
</tr>
</table>
END;
?>-
mrpaulfrank
- Forum Commoner
- Posts: 33
- Joined: Sun Jun 23, 2002 3:39 am
whats wrong with this code? im getting a parse error and its not creating the table within a table. im trying to make each loop a table (each table having 4 rows) in a larger table so that the results will be columns in one row of the larger table (make sense?):
Code: Select all
<table width="800" border="0" cellspacing="0">
<tr>
<?php
$genre = "comedy";
$query_Recordset1 = "SELECT * FROM test WHERE genre = '$genre'";
$Recordset1 = mysql_query($query_Recordset1, $db) or die(mysql_error());
while($row_Recordset1 = mysql_fetch_assoc($Recordset1))
{
$image = $row_Recordset1ї'image'];
if($genre = "comedy")
{
echo "<table width="200" border="0" cellspacing="0">"."<tr>".
"<td><A href=backs/$image.jpg><IMG SRC=images/$image.jpg></A>"."</td>".
"<td>Title: ".$row_Recordset1ї'title']."</td>".
"<td>Format: ".$row_Recordset1ї'format']."</td>".
"<td>Make: ".$row_Recordset1ї'make']."</td></tr>";
}
}
?>
</tr>
</table>- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
The code I posted was the code that you are now using with the obvious parse errors in the original code removed...
Anyway,
Please also note that although it won't cause any parse errors it will cause you a headache,
has to be
in order to work.
Mac
Anyway,
Code: Select all
<table width="800" border="0" cellspacing="0">
<tr>
<?php
$genre = 'comedy';
$query_Recordset1 = "SELECT * FROM test WHERE genre = '$genre'";
$Recordset1 = mysql_query($query_Recordset1, $db) or die(mysql_error());
while($row_Recordset1 = mysql_fetch_assoc($Recordset1))
{
$image = $row_Recordset1ї'image'];
if ($genre == 'comedy') {
echo <<<END
<td>
<table cellpadding="0" cellspacing="2">
<tr>
<td><a href="backs/$image.jpg"><img src="images/$image.jpg"></a></td>
</tr>
<tr>
<td>Title: {$row_Recordset1ї'title']}</td>
</tr>
<tr>
<td>Format: {$row_Recordset1ї'format']}</td>
</tr>
<tr>
<td>Make: {$row_Recordset1ї'make']}</td>
</tr>
</table>
</td>
END;
}
}
?>
</tr>
</table>Code: Select all
if ($genre = 'comedy') {Code: Select all
if ($genre == 'comedy') {Mac
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
-
mrpaulfrank
- Forum Commoner
- Posts: 33
- Joined: Sun Jun 23, 2002 3:39 am