SELECT * FROM weight WHERE month='August' AND year='2010' OR year='2010'
SELECT * FROM weight WHERE year='2010'
SELECT * FROM weight WHERE (month='August' AND year='2010') OR year='2011'
if (isset($_GET['month'], $_GET['year'])) { $month = mysql_escape_string($month); $year = mysql_escape_string($year); $sql = "SELECT * FROM weight WHERE month = '$month' AND year = '$year'"; } else if (isset($_GET['month'])) { $month = mysql_escape_string($month); $sql = "SELECT * FROM weight WHERE month = '$month'"; } else if (isset($_GET['year'])) { $year = mysql_escape_string($year); $sql = "SELECT * FROM weight WHERE year = '$year'"; } $result = mysql_query($sql);
<input type="text" id="year" value="Enter Year"/> <button type="button" onclick="location.href='./date.php?year='+document.getElementById('year').value;">Go To</button></div>
<input type="text" id="month" value="Enter Month"/> <input type="text" id="year1" value="Enter Year"/> <button type="button" onclick="location.href='./date.php?month='+document.getElementById('month').value'&year='+document.getElementById('year1').value;">Go To</button
What's this mysql_escape_string chap and what does it do for me?
(As I'm sure you're aware you code works perfectly well also :D )
<form action="./date.php" method="get"> <input type="text" id="year" name="year" value="Enter Year" /> <button type="submit">Go To</button> </form> <form action="./date.php" method="get"> <input type="text" id="month" name="month" value="Enter Month/> <input type="text" id="year1" name="year" value="Enter Year" /> <button type="submit">Go To</button> </form>
<form method="get" action="date.php"> <input name="month" type="text" value="Enter month" /> <input name="year" type="text" value="Enter year" /> <button type="submit">Go To</button> </form>
I see, yeah I guess I should be using escapes then.
Fantastic stuff, I can now be a sad bastard and track my weight via a pretty(ish) graph (using PHPGraphLib).
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> ";