Page 1 of 1

return problem

Posted: Mon Jul 01, 2002 1:47 am
by mrpaulfrank
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?

Posted: Mon Jul 01, 2002 1:59 am
by garymailer
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)) 
&#123; 
$image = $row_Recordset1&#1111;'image']; 
if($genre = "comedy") 
&#123; 
echo "<A href=backs/$image.jpg><IMG SRC=images/$image.jpg></A>". 
"Title: ".$row_Recordset1&#1111;'title']." 
"Format: ".$row_Recordset1&#1111;'format']." 
"Price: ".$row_Recordset1&#1111;'make'].".
<br />"; 
&#125; 
&#125;

Posted: Mon Jul 01, 2002 3:28 am
by mrpaulfrank
it doesnt work:( all that does is make the entire thing one long string of text. what i want is this:

image
title
format
make

then the next one displayed a little over horizontally, and so on...
is there some sort of a 'tab' tag i can use to do this?? im completely lost.
thanks

Posted: Mon Jul 01, 2002 3:32 am
by hob_goblin
piece of cake

Code: Select all

echo "<table cellpadding="0" cellspacing="5"><tr>";
while($row_Recordset1 = mysql_fetch_assoc($Recordset1)) 
&#123; 
$image = $row_Recordset1&#1111;'image']; 
if($genre = "comedy") 
&#123; 
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&#1111;'title']." 
"</td></tr><tr><td>Format: ".$row_Recordset1&#1111;'format']." 
"</td></tr><tr><td>Price: ".$row_Recordset1&#1111;'make']."</td></tr></table></td>"; 
&#125; 
&#125; 
echo "</tr></table>";

Posted: Mon Jul 01, 2002 4:23 am
by mrpaulfrank
wow, im extremely lost. from what i see youre trying to echo a table before you echo the info from mysql which will be inserted into the table?? i still cant get it to work. maybe if someone can explain to me what i should be trying to do...i dunno. thanks

Posted: Mon Jul 01, 2002 4:35 am
by twigletmac
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:

Code: Select all

<?php
echo <<<END
<table cellpadding="0" cellspacing="5">
<tr>
END; 
while($row_Recordset1 = mysql_fetch_assoc($Recordset1)) &#123; 
	$image = $row_Recordset1&#1111;'image']; 
	if ($genre == 'comedy') &#123; 
		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: &#123;$row_Recordset1&#1111;'title']&#125;</td>
		</tr>
		<tr>
			<td>Format: &#123;$row_Recordset1&#1111;'format']&#125;</td>
		</tr>
		<tr>
			<td>Price: &#123;$row_Recordset1&#1111;'make']&#125;</td>
		</tr>
		</table>
	</td>
END;
	&#125; 
&#125; 
echo <<<END
</tr>
</table>
END; 
?>
Mac

Posted: Mon Jul 01, 2002 6:09 pm
by mrpaulfrank
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)) 
&#123;
	$image = $row_Recordset1&#1111;'image'];	
	if($genre = "comedy")
	&#123;
	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&#1111;'title']."</td>". 
    "<td>Format: ".$row_Recordset1&#1111;'format']."</td>".
	"<td>Make: ".$row_Recordset1&#1111;'make']."</td></tr>";
	&#125;
&#125;
?>
  </tr>
</table>

Posted: Tue Jul 02, 2002 1:55 am
by twigletmac
The code I posted was the code that you are now using with the obvious parse errors in the original code removed...

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)) 
&#123; 
   $image = $row_Recordset1&#1111;'image'];    
   if ($genre == 'comedy') &#123; 
	   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: &#123;$row_Recordset1&#1111;'title']&#125;</td> 
      </tr> 
      <tr> 
         <td>Format: &#123;$row_Recordset1&#1111;'format']&#125;</td> 
      </tr> 
      <tr> 
         <td>Make: &#123;$row_Recordset1&#1111;'make']&#125;</td> 
      </tr> 
      </table> 
   </td> 
END;
   &#125; 
&#125; 
?> 
  </tr> 
</table>
Please also note that although it won't cause any parse errors it will cause you a headache,

Code: Select all

if ($genre = 'comedy') &#123;
has to be

Code: Select all

if ($genre == 'comedy') &#123;
in order to work.

Mac

Posted: Tue Jul 02, 2002 2:31 am
by hob_goblin
sorry ;-) it was rather early in the morning, when parse errors seem to roam my mind

Posted: Wed Jul 03, 2002 4:53 am
by mrpaulfrank
all thes problems were because i was not escaping the quotes! haha. thanks guys