Jump to content

sblake161189

Members
  • Posts

    47
  • Joined

  • Last visited

    Never

Everything posted by sblake161189

  1. Hi Guys, I am normally switched on when it comes to PHP mysql_query's but for some reason I cannot work this one out. Its probably something daft! I have a SELECT * query's which then displays results in the table. But for some reason it isnt showing every result (i.e. some properties are missing). I have worked out they are the properties where there is no customer, orderdetail or payment linked to it. I would like it to show ALL results regardless of wether a customer, order or payment is attached it. Here is my code: <?php // Find All Properties $resulta = mysql_query("SELECT * FROM yea_properties ORDER BY PROPERTY_ID DESC"); if(mysql_num_rows($resulta)==0) { echo "No properties in database."; } else { ?> <table width="990" border="0"> <tr> <td><strong>Property ID</strong></td> <td><strong>Address</strong></td> <td><strong>Created</strong></td> <td><strong>Customer</strong></td> <td><strong>Order</strong></td> </tr> <?php while($property=mysql_fetch_array($resulta)){ $propertyID = $property['PROPERTY_ID']; // Find Details of Prop/Customer Link $resultb = mysql_query("SELECT * FROM yea_link_prop_cust WHERE PROPID = '$propertyID'"); $link = mysql_fetch_array($resultb); $userID = $link['USERID']; // Find Details of Customer $resultc = mysql_query("SELECT * FROM yea_customers WHERE USERID = '$userID'"); while($customer=mysql_fetch_array($resultc)){ // Find Details of Latest Order with Property $resultd = mysql_query("SELECT * FROM yea_orderdetails WHERE DetailPropertyID = '$propertyID' ORDER BY DetailOrderID DESC Limit 0,1"); while($order=mysql_fetch_array($resultd)){ $orderID = $order['DetailOrderID']; // Find Details of Payment $resulte = mysql_query("SELECT * FROM yea_payments WHERE orderID = '$orderID'"); $payment = mysql_fetch_array($resulte); $paymentID = $payment['paymentID']; ?> <tr> <td><a href="view-property.php?propertyID=<?php echo $propertyID; ?>">View Property #<?php echo $propertyID; ?></a></td> <td><?php echo $property['ADDRESS_1']; ?> <?php echo $property['ADDRESS_2']; ?>, <?php echo $property['ADDRESS_3']; ?>, <?php echo $property['TOWN']; ?>, <?php echo $property['POSTCODE1']; ?> <?php echo $property['POSTCODE2']; ?></td> <td><?php echo $property['CREATE_DATE']; ?></td> <td><a href="view-customer.php?userID=<?php echo $customer['USERID']; ?>">Customer #<?php echo $customer['USERID']; ?> (<?php echo $customer['FIRST_NAME']; ?> <?php echo $customer['LAST_NAME']; ?>)</a></td> <td><a href="view-order.php?orderID=<?php echo $orderID; ?>&paymentID=<?php echo $paymentID; ?>">View Order #<?php echo $orderID; ?></a></td> </tr> <?php }}}} ?> </table> Any help would be much appreciated
  2. Just incase any of you are confused... The reason it didnt like <div id="description"> was because when it was looking for getElementByID('description'); it was finding the META 'description' tag rather than my DIV. I have changed it in the above code to <div id="blogdescription"> as this was then different to the META. Changing that and the above code made it work
  3. Hi Guys, Thanks for all your help... I have found the following works... it might not be the tidiest solution, but it does the job... <?php $url="http://www.example.com?id=1"; $html = file_get_contents($url); $doc = new DOMDocument(); @$doc->loadHTML($html); $doc = $doc->getElementById('blogdescription'); $images = $doc->getElementsByTagName('img'); foreach ($images as $image) { echo $image->getAttribute('src')."<br/>"; } ?> Cheers
  4. Hi there, Nope its the only div with that ID as per W3C validations... Here is the code within the page its looking at... <div id="description"> <?php echo($blog['description']); ?> </div> Although its a foreach it still should find just that one instance of the <div id="description"> in there. Thanks for your help :-)
  5. Thanks for your reply... I have tried that but unless I am being stupid it doesnt find the <div id="description"> <?php $url="http://www.example.com?id=1"; $html = file_get_contents($url); $doc = new DOMDocument(); @$doc->loadHTML($html); $divs = $doc->getElementByID('description'); foreach ($divs as $div) { echo "Found the description div <br />"; } ?> It finds nothing and appears blank...
  6. Hi All, I have the following code to find all the image src's for all the images within a current page. However I would like to adapt it so it only looks within the <div id="description">. Any ideas on how to do that? I have tried Googling with not much look. <?php $url="http://www.example.com?id=1"; $html = file_get_contents($url); $doc = new DOMDocument(); @$doc->loadHTML($html); $images = $doc->getElementsByTagName('img'); foreach ($images as $image) { echo $image->getAttribute('src')."<br/>"; } ?> Cheers Guys!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.