Page 2 of 2 FirstFirst 12
Results 11 to 11 of 11

Thread: MySQL Database Query problem

  1. #11
    Join Date
    May 2010
    Location
    Rosebud West, Australia
    Posts
    33
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Well actually each of those is a php include with the code for a specific query and for putting the results in a table.

    I realise this is a lot of files but it's a lot of different queries also.

    the overall code is the same except for the specific keywords in the query (ie. $result = mysql_query("SELECT * FROM ysp
    WHERE Heading='Anodes' AND `Description` LIKE '%4JH-DTE%' OR Heading='Anodes' AND `Description` LIKE '%JH Series%'")or die(mysql_error());
    )

    But if I remove the parts that are the same in all of them and make them includes of their own that they all reference to I just find it more complicated because I'll have includes referencing includes. I guess it's more tidy that way but it would also be a pain to go over the thousands of files I already have and modify them again, even with Notepad++

    Edit: I actually tried this approach anyway and found that it broke it. Example code is below, not sure what I did wrong.

    ../yanmar parts/ajaxpages/2S/2S/anodes.php :

    Code:
    <h1>Anodes</h1>
    <?php include("yanmar/connectysp.php"); ?>
    
    // Get specific items using query from the "ysp" table and stores them in result variable
    $result = mysql_query("SELECT * FROM ysp
    WHERE Heading='Anodes' AND `Description` LIKE '%2S%' OR Heading='Anodes' AND `Description` LIKE '%2S Series%'")or die(mysql_error());
    
    <?php include("yanmar/drawresults.php"); ?>
    ../includes/yanmar/connectysp.php :
    Code:
    <?php
    mysql_connect("localhost", "djvkcom_wbs", "wbs1") or die(mysql_error());
    mysql_select_db("djvkcom_ysp") or die(mysql_error());
    ../includes/yanmar/drawresults.php :
    Code:
    // Display the contents of the entry 
    echo "<table border='1' style='background-color: #ffffff; text-align:center;'>";
    echo "<tr> <th>Image</th> <th>Item</th> <th>Engine Models</th> <th>Part No.</th> <th>Price</th> </tr>";
    
    // keeps getting the next row until there are no more to get
    while($row= mysql_fetch_array( $result )) {
    	// Print out the contents of each row into a table
    	echo "<tr><td>"; 
    	echo "<img src=\"".$row['Image']."\">";
    	echo "</td><td>";
    	echo $row['SubHeading'];
    	echo "</td><td>"; 
    	echo $row['Description'];
    	echo "</td><td>";
    	echo $row['PartNo'];
    	echo "</td><td>"; 
    	echo $row['Price'];
    	echo "</td></tr>"; 
    } 
    
    echo "</table>";
    ?>
    Last edited by djvk87; 06-29-2010 at 11:07 PM. Reason: added information

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •