[Wolves] Mysql join help
Constantin Orăsan
c.orasan at gmail.com
Fri Jun 28 17:49:00 UTC 2013
Hello,
Thanks for that - getting there now - now have:
>
>
> echo "All Repairs Needed";
> $query = "SELECT property.id, property.address1, property.address2,
> repairs.repairtype, repairs.lastinspectedby, repairs.timelogged
> FROM property, repairs
> WHERE property.id = repairs.pid";
>
> Which as a mysql select query gives me what I want, having trouble with
> creating page
>
> adding this
> $result = mysql_query($query);
> $num_rows = mysql_num_rows($result);
> $row = mysql_fetch_array($result);
> for($i=1; $i <= $num_rows; $i++)
>
> {
> print("<TD wrap style=\"wrap: 1 solid #800000\">".$row["repairtype"]**."
> </td>");
> (more rows)
> }
>
> just prints the first line of data over and over again.
>
> how do I get it to clock up and print the next row?
>
>
The problem is how you fetch the data from the database. mysql_fetch_array
returns only one row (
http://php.net/manual/en/function.mysql-fetch-array.php). You want to warp
it in a while:
while($row = mysql_fetch_array($result)) {
print("<TD wrap style=\"wrap: 1 solid #800000\">".$row["repairtype"]**."
</td>");
}
Constantin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.lug.org.uk/pipermail/wolves/attachments/20130628/973d5e8b/attachment.html>
More information about the Wolves
mailing list