Jump to content

Barny74

Members
  • Posts

    75
  • Joined

  • Last visited

Posts posted by Barny74

  1. I have coded a contact form , but for some reason I am not actually getting the email , but the php code has no errors and the form returns a success message. I have removed my email address from the code here. Appreciate any help.

     

     

    Contact form

    <body>
    <div class='formbody'>
    
    <link href='http://fonts.googleapis.com/css?family=Lato' rel='stylesheet' type='text/css'>
    
    <form id="contact-form" action="send.php" method="POST">
    
      <p>Hi</p>
      <p>My
        <label for="your-name">name</label> is
        <input type="text" name="your-name" id="your-name" minlength="3" placeholder="(your name here)" required> and</p>
    
      <p>my
        <label for="email">email address</label> is
        <input type="email" name="your-email" id="email" placeholder="(your email address)" required>
      </p>
    
      <p> I have a
        <label for="your-message">message</label> for you,</p>
    
      <p>
        <textarea name="your-message" id="your-message" placeholder="(your msg here)" class="expanding" required></textarea>
      </p>
      <p>
        <button type="submit">
          <svg version="1.1" class="send-icn" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="100px" height="36px" viewBox="0 0 100 36" enable-background="new 0 0 100 36" xml:space="preserve">
            <path d="M100,0L100,0 M23.8,7.1L100,0L40.9,36l-4.7-7.5L22,34.8l-4-11L0,30.5L16.4,8.7l5.4,15L23,7L23.8,7.1z M16.8,20.4l-1.5-4.3
        l-5.1,6.7L16.8,20.4z M34.4,25.4l-8.1-13.1L25,29.6L34.4,25.4z M35.2,13.2l8.1,13.1L70,9.9L35.2,13.2z" />
          </svg>
          <small>SEND PLEASE</small>
        </button>
      </p>
    </form>
        <script src="assets/js/jquery.min.js"></script>
        <script src="assets/bootstrap/js/bootstrap.min.js"></script>
        <script src="assets/js/bs-animation.js"></script>
         <script src="assets/js/index.js"></script>
        </div>
    </body>
    </html>
    

    Send.php

        <?php 
    $page='contactus';
    include('header.php');
    include('navbar.php');
    
    ?>
    
    <?php
    $to = 'removed';
    $name = TRIM (stripslashes($_POST['your-name']));
    $email = TRIM (stripslashes($_POST['your-email']));
    $message = TRIM (stripslashes($_POST['your-message']));
    $subject = 'Message';
    
    
    $name = 'Name: ';
    $email= 'From:';
    $message= 'Message: ';
    
    
    
    
    
    if( mail($to, $subject, $name , $email , $message) ){
            echo 'success';
    
    }
    
    else{
    
        print('There has been a small error . Sorry!!');
    }
    
    ?>
    
  2. Hi,

     

    I have been trying to code some javascript to detect when an image does not load , but having no luck as new to javascript.

     

    I am trying to replace the below , if it does not load,

    echo "<img src='".$row ['url_img']."' /><br />";
    

    with an image called no_img.jpg

     

    	if (isset($_GET['id'])) {
        $sql = "SELECT w.whisky_name
    , price
    , date
    , avprice 
    ,url_img 
    ,whisky_id
    FROM test_db t
    JOIN 
        whisky w USING (whisky_id)
    JOIN (
        SELECT whisky_id
        , AVG(price) as avprice 
        FROM test_db 
        WHERE whisky_id = :id
        GROUP BY whisky_id
        ) avcalc USING (whisky_id)
    ORDER BY date DESC 
    LIMIT 1";
    
        $stmt = $conn->prepare($sql);
        $stmt->execute( array( 'id' => $_GET['id']) );
        $row = $stmt->fetch();
    
    
        echo "<div class='details'>";
            echo "<br>";
            echo $row['whisky_name'];
            echo "<br><br>";
            echo "Average price based on all sales" ;
            echo"<br><br>";
            echo "<div class= 'price'>";
            echo " £";
            echo floor ($row ['avprice']);
            echo "</div>";
            echo "<br>";
            echo "<div class='img_border'>";
            echo "<img src='".$row ['url_img']."' /><br />";
            echo "<a href='records.php?id={$row['whisky_id']}' >Click here for more detailed results</a>";
            echo "<br>";
        echo "</div>";
    }
    	?>
    

    Appreciate the help

  3. Hi. I woudl like to have an alt image instead of alt text. I am trying the below for thee text , but cant figure out how to have an alt img , the alt image is called no_img.jpg

     echo "<img src='".$row ['url_img']."' alt='Sorry no image available'/><br>";
    

    Thanks

  4. Quick question. I just uploaded the website to a online test site , I have added the database and connected etc and the search works fine , but when I click on one of the results I get the following error

     

    Parse error: syntax error, unexpected '[', expecting ')' in details1.php on line 40

     

    workds perfectly offline and I am connecting ok because I can do an initial search.

     

    I am in a holding pattern with support... yawn

    <?php
    
    	$page='details';
    	include('header.php');
    	include ('navbar.php'); 
    	include ('connect.php');
    
    	if (isset($_GET['id'])) {
        $sql = "SELECT w.whisky_name
    , price
    , date
    , avprice 
    ,url_img 
    ,whisky_id
    FROM test_db t
    JOIN 
        whisky w USING (whisky_id)
    JOIN (
        SELECT whisky_id
        , AVG(price) as avprice 
        FROM test_db 
        WHERE whisky_id = :id
        GROUP BY whisky_id
        ) avcalc USING (whisky_id)
    ORDER BY date DESC 
    LIMIT 1";
    
    
    
        $stmt = $conn->prepare($sql);
        $stmt->execute( [ 'id' => $_GET['id'] ] );
        $row = $stmt->fetch();
        echo "<div class='details'>";
            echo "<br>";
            echo $row['whisky_name'];
            echo "<br><br>";
            echo "Average price based on all sales" ;
            echo"<br><br>";
            echo "<div class= 'price'>";
            echo " £";
            echo floor ($row ['avprice']);
            echo "</div>";
            echo "<br>";
            echo "<div class='img_border'>";
            echo "<img src='".$row ['url_img']."' /><br />";
            echo "</div>";
            echo "<br>";
            echo "<a href='records.php?id={$row['whisky_id']}' >Click here for more detailed results</a>";
            echo "<br>";
        echo "</div>";
    }
    	?>
    
    
    
    

    line 39 $stmt = $conn->prepare($sql);

     

    line 40 $stmt->execute( [ 'id' => $_GET['id] ] );

  5. Thanks for the reaponse.

     

    1. I currently download all the info into excel format and then save as a csv. It basically has the following headings. Name , date of last sale , sale price of last sale , auction link , image link , lot number. I usually download it then copy the info into a CSV that has all records in it.

  6. Forgot i had already asked this in a different question. Sorry.

     

    I do have a query. When i have a completly new whisky to add into the DB or add in a new auction sale , Do I do it via CSV or myphpadmin ?and if i did would i need to run the code that you kindly sent me to earlier. I.e populatimg the whisky table with the unique name (#3) and then #4 and #5

  7. Ha ha , back again...I know I need to add a WHILE loop to get this going , but how would I get all results showing for the specific whisky. Just not sure on the WHILE loop. Only one result showing at the moment.

     

    http://imgur.com/a/qilCS

    if (isset($_GET['id'])) {
    
            $sql = "SELECT w.whisky_name
            , price
            , date
            , avprice 
            ,url_img 
            ,whisky_id
            FROM test_db t
            JOIN 
                whisky w USING (whisky_id)
            JOIN (
                SELECT whisky_id
                , AVG(price) as avprice 
                FROM test_db 
                WHERE whisky_id = :id
                GROUP BY whisky_id
                ) avcalc USING (whisky_id)
            ORDER BY date DESC 
            LIMIT 1";
               
        $stmt = $conn->prepare($sql);
        $stmt->execute( [ 'id' => $_GET['id'] ] );
        while( $row = $stmt->fetch() ) {
        echo "<div class='records'>";
            echo "<br>";
            echo $row['whisky_name'];
            echo "<br><br>";
            echo $row ['date'];
            echo"<br><br>";
            echo " £";
            echo floor ($row ['price']);
            echo "<br>";
            echo "<br>";
            echo "<br>";
        echo "</div>";
    }
    }
    	?>
    
  8. AH ok. I was a bit confused as i was querying test_db and there is not url_img or whsky_id in this db. But I have added them and thats all good now.

     

    So once agian thanks so much and I really appreciate you taking the time to assit me with this.

     

    I will work on the final page now and hopefully work it out now I have a good base to work from, but If it is ok I will ask if I have any problems

     

    Thnanks again.

  9. Ah ok, so much to take in I did not relaise that. Thanks. So do I need to also connect to the whisky table to pull the img down, also have an error on whisky_id , as per pic,

     

    http://imgur.com/a/grgaZ

    if (isset($_GET['id'])) {
        $sql = "SELECT w.whisky_name
    , price
    , date
    , avprice 
    FROM test_db t
    JOIN 
        whisky w USING (whisky_id)
    JOIN (
        SELECT whisky_id
        , AVG(price) as avprice 
        FROM test_db 
        WHERE whisky_id = :id
        GROUP BY whisky_id
        ) avcalc USING (whisky_id)
    ORDER BY date DESC 
    LIMIT 1";
    
        $stmt = $conn->prepare($sql);
        $stmt->execute( [ 'id' => $_GET['id'] ] );
        $row = $stmt->fetch();
        echo "<div class='details'>";
            echo "<br>";
            echo $row['whisky_name'];
            echo "<br><br>";
            echo "Average price based on all sales" ;
            echo"<br><br>";
            echo "<div class= 'price'>";
            echo " £";
            echo floor ($row ['avprice']);
            echo "</div>";
            echo "<br>";
            echo "<div class='img_border'>";
            echo "<img src='".$row ['url_img']."' /><br />";
            echo "</div>";
            echo "<br>";
            echo "<a href='records.php?id={$row['whisky_id']}' >Click here for more detailed results</a>";
            echo "<br>";
        echo "</div>";
    }
    	?>
    
    
    
    

     

  10. Ok thank you , I have update the code but now it just goes back to a page with no database content, I will keep the dates etc for later andif I can just get the name ,avg price that would be great , and I keep the code in for the dates last sold and price last sold so I can add that in later. really sorry about this and really appreciat the help

     

    http://imgur.com/a/DPSr4

     

    details1.php

    <?php
    
    	$page='details';
    	include('header.php');
    	include ('navbar.php'); 
    	include ('connect.php');
    
    	if (isset($_GET['id'])) {
        $sql = "SELECT w.whisky_name
    , price
    , date
    , avprice 
    FROM test_db t
    JOIN whisky w USING (whisky_id)
    JOIN (
        SELECT whisky_id,
        , AVG(price) as avprice 
        FROM test_db 
        GROUP BY whisky_id
        ) avcalc USING (whisky_id)
    WHERE w.whisky_id = 1
    ORDER BY date DESC 
    LIMIT 1";
    
    
        $stmt = $conn->prepare($sql);
        $stmt->execute( [ 'id' => $_GET['id'] ] );
        $row = $stmt->fetch();
        echo "<div class='details'>";
            echo "<br>";
            echo $row['whisky_name'];
            echo "<br><br>";
            echo "Average price based on all sales" ;
            echo"<br><br>";
            echo "<div class= 'price'>";
            echo " £";
            echo floor ($row ['avprice']);
            echo "</div>";
            echo "<br>";
            echo "<div class='img_border'>";
            echo "<img src='".$row ['url_img']."' /><br />";
            echo "</div>";
            echo "<br>";
            echo "<a href='records.php?id={$row['whisky_id']}' >Click here for more detailed results</a>";
            echo "<br>";
        echo "</div>";
    }
    	?>
    
    
    
×
×
  • 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.