<div dir="ltr">yes i was going to mention those variable names lol <br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 9 July 2013 12:01, David Goodwin <span dir="ltr"><<a href="mailto:david@codepoets.co.uk" target="_blank">david@codepoets.co.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br>
On 9 Jul 2013, at 11:46, Wayne Morris <<a href="mailto:waynelists@machx.co.uk">waynelists@machx.co.uk</a>> wrote:<br>
<br>
> Hi,<br>
><br>
> I have the following select which loses one row from the database - ie it produces 4 rows instead of the correct 5.<br>
> And ideas what I am doing wrong?<br>
<br>
</div>Yes.<br>
<div class="im"><br>
><br>
> $queryz = "SELECT *<br>
> FROM property<br>
> WHERE postcode like '%$postcodevoid%' and let = '1'<br>
><br>
> ";<br>
><br>
<br>
</div>1. Using silly variable names.<br>
2. Probably writing code that's vulnerable to SQL injection. Please make sure you run $postcodevoid = mysql_real_escape_string($postcodevoid) or the equivalent.<br>
<div class="im"><br>
<br>
> $resultz = mysql_query($queryz);<br>
> $num_rows = mysql_num_rows($resultz);<br>
> $rowz = mysql_fetch_array($resultz);<br>
><br>
> for($i=1; $i <= $num_rows; $i++)<br>
><br>
<br>
</div>3. Wrapping the while loop in a for loop …. and starting that loop count at 1, instead of 0.<br>
<div class="im"><br>
><br>
> while($rowz = mysql_fetch_array($resultz)) {<br>
><br>
> print("<TABLE border=\"1\" cellspacing\"0\" cellpadding=\"0\" width=100% style=\"font-size: 10pt\">\n");<br>
> print("<TD width=10% wrap style=\"wrap: 1 solid #800000\">".$rowz["address1"]." </td> ". " ");<br>
> print("<TD width=5% wrap style=\"wrap: 1 solid #800000\">".$rowz["address2"]." </td>");<br>
> print("<TD width=5% wrap style=\"wrap: 1 solid #800000\">".$rowz["postcode"]." </td>");<br>
> }<br>
<br>
<br>
</div>You probably just want :<br>
//...<br>
mysql_connect(….);<br>
mysql_select_db(….);<br>
// ….<br>
$postcode = mysql_real_escape_string($_GET['postcode']); /* I presume */<br>
$query = "SELECT * FROM property WHERE postcode like '%$postcode%' AND let = '1'";<br>
<br>
$result = mysql_query($query);<br>
while($row = mysql_fetch_array($result)) {<br>
echo "…….blah bah blah {$row['address1']} blah blah blah {$row['address2']} …. \n";<br>
}<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
David.<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
<br>
_______________________________________________<br>
Wolves LUG mailing list<br>
Homepage: <a href="http://www.wolveslug.org.uk/" target="_blank">http://www.wolveslug.org.uk/</a><br>
Mailing list: <a href="mailto:Wolves@mailman.lug.org.uk">Wolves@mailman.lug.org.uk</a><br>
Mailing list home: <a href="https://mailman.lug.org.uk/mailman/listinfo/wolves" target="_blank">https://mailman.lug.org.uk/mailman/listinfo/wolves</a><br>
</div></div></blockquote></div><br></div>