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 "
...
";
}
?>
I agree on the regex front. It seems to have been the fix for loads of stuff I've asked on here.
Also (hug) the extra braces worked!
Ah, thought you might have done. However, it shouldn't be necessary - the line breaks shouldn't get added at all - content between code isn't supposed to be changed (excluding font/colour formatting).
Dunno what the cause is though - I did go look at the code Matt referred to and it's far too much effort trying to decipher it all, especially as tired as I currently am.