image1.jpg,image2.jpg,image3.jpg,image4.jpg
{$row[images]}
<img src="image1.jpg" /><img src="image2.jpg" /><img src="image3.jpg" /><img src="image4.jpg" />
$blah = split(",", $row[images]); foreach ($blah as $beep) { echo "<img src=\"" . $beep . "\" />"; }
And how do I pop that within a current big echo?
I'm trying (honest :$ )
$car = $_GET['car']; $query = "SELECT * FROM cars WHERE carcode = '$car' "; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) echo " <table> <tr> <th rowspan='5'><a href='#'><img src='./photos/{$row[thumb]}' /></a> <br /> <td colspan='2' width='300px'><a href='car.php?car={$row[carcode]}'>{$row[title]}</a></td> </tr> <tr> <td width='250px'>{$row[year]}<br /> {$row[mileage]}<br /> {$row[engine]}<br /> {$row[fuel]}<br /> {$row[gearbox]}<br /> </td> <td width='250px'>{$row[colour]}<br /> {$row[mot]}<br /> {$row[tax]}<br /></td> </tr> <tr> <td colspan='2'>{$row[extra]}</td> </tr> <tr> <td colspan='2' align='right' valign='bottom'><b>£{$row[price]}</b></td> </tr> <tr> <td colspan='2'>FULL WIDTH</td> </tr> </table> ";
I think I'm doing this totally wrong, because I actually want to do some stuff with the output from the other rows depending on what it is rather than just showing their content.
Back to the drawing board possibly.
$blah = split(",", $row[images]); foreach ($blah as $beep) { $stringading .= "<img src=\"" . $beep . "\" />"; }
$car = $_GET['car']; $query = "SELECT * FROM cars WHERE carcode = '$car' "; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) echo " <table> <tr> <th rowspan='5'><a href='#'><img src='./photos/{$row[thumb]}' /></a> <br /> <td colspan='2' width='300px'><a href='car.php?car={$row[carcode]}'>{$row[title]}</a></td> </tr> <tr> <td width='250px'>{$row[year]}<br /> {$row[mileage]}<br /> {$row[engine]}<br /> {$row[fuel]}<br /> {$row[gearbox]}<br /> </td> <td width='250px'>{$row[colour]}<br /> {$row[mot]}<br /> {$row[tax]}<br /></td>" . $stringading . " </tr> <tr> <td colspan='2'>{$row[extra]}</td> </tr> <tr> <td colspan='2' align='right' valign='bottom'><b>£{$row[price]}</b></td> </tr> <tr> <td colspan='2'>FULL WIDTH</td> </tr> </table> ";
$blah = split(",", $row[images]); $stringading = "tr"; foreach ($blah as $beep) { $stringading .= "<td><img src=\"" . $beep . "\" /></td>"; } $stringading .= "</tr>";
That shows all the images (cheer)
But it breaks everything else and nothing else outputs :C
function func_name() { while (1) { if ($condition) { func_name(); } if ($other_condition) { break; // exit the while loop } } }
$string = '<img src="' . replace( ',' , '" /><img src="' , $string ) . '" />';
$string = preg_replace( '(?:^|,)([^,]+)' , '<img src="$1" />' , $string );
1. I will start a new thread next time I want coding help :C
2. I really need to learn how to use regex stuff.
3. Nothing wrong with tables (maybe). But I doubt they're the issue here.
<?php mysql_connect("localhost","user","pass"); mysql_select_db("cogs"); $car = $_GET['car']; $query = "SELECT * FROM cars WHERE carcode = '$car' "; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) $blah = split(",", $row[images]); foreach ($blah as $beep) { $stringading .= "<img src=\"" . $beep . "\" />"; } echo " <table> <tr> <th rowspan='5'><a href='#'><img src='./photos/{$row[thumb]}' /></a> <br /> " . $stringading . " <br /> <td colspan='2' width='300px'><a href='car.php?car={$row[carcode]}'>{$row[title]}</a></td> </tr> <tr> <td width='250px'>Year - {$row[year]}<br /> Mileage - {$row[mileage]}<br /> Engine - {$row[engine]}<br /> Fuel - {$row[fuel]}<br /> Gearbox - {$row[gearbox]}<br /> </td> <td width='250px'>Body/Doors - <br /> Colour - {$row[colour]}<br /> MOT - {$row[mot]}<br /> Tax - {$row[tax]}<br /></td> </tr> <tr> <td colspan='2'>{$row[extra]}</td> </tr> <tr> <td colspan='2' align='right' valign='bottom'><b>£{$row[price]}</b></td> </tr> <tr> <td colspan='2'>FULL WIDTH</td> </tr> </table> "; ?>
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$blah = split(",", $row[images]);
foreach ($blah as $beep)
{
$stringading .= "<img src=\"" . $beep . "\" />";
}
echo "
...
";
}
?>