Jump to content

Query acting badly


simcoweb

Recommended Posts

Here's the code for the query:

 

<?php
include 'db_config.php';
/**
* @author rockmetal
* @copyright 2007
*/

// query for extracting lenders from amember database
$category = strip_tags(trim($_POST['category']));
$loantype = strip_tags(trim($_POST['loan_type']));
$loanamount = strip_tags(trim($_POST['loan_size']));

$sql = "SELECT * FROM amember_members WHERE is_lender='Yes' AND '$category' IN (category_1, category_2, category_3, category_4, category_5) AND loan_type='$loantype' AND loan_size='$loanamount' ORDER BY top_3 LIMIT 10";

$results = mysql_query($sql) or die(mysql_error());
$numrows = mysql_num_rows($results) or die(mysql_error());

if($numrows == 0){
echo "<h3>No Results Found</h3><br>
<p class='bodytext'>No lenders matched your search criteria. Try modifying the search parameters for broader results.<br>\n";
} else {
// create display of results in abbreviated format
while ($row = mysql_fetch_array($results)) {
	echo "<table width='550' border='0'>
	<tr colspan='2'><td class='lendertitle'>".$row['company_name']."</td></tr>
	<tr><td class='lenderdesc'>".$row['company_desc']."</td></tr>
	<tr><td>Rating:". include('star_rating')."</td><td><a class='lenderlink' href='loanrequest.php?lenderid=".$row['member_id'].">Full Details</a></td></tr>
	</table><br />\n ";
}
}
?>

 

The database DOES contain at least one record that would meet the requirements of the query. However, nothing displays. Furthermore, if there were no results then it should display the message to that affect. Instead the page is completely blank when the search is performed. Scratching my head  ???

Link to comment
Share on other sites

Ok, that's what was breaking it. The rating include. Actually it's supposed to be there but I didn't modify the code to correct syntax. Here's the recommended 'tag' they suggest using. However, this is including additional PHP echo commands that I don't need since it will be inserted into a block of HTML that is already being echoed.

 

<? echo pullRating(35,false,false,false,NULL); ?>

 

So, say I wanted to place this where the include('star_rating') code is now. How/what would I modify to make this work? I've tried a few combos but my PHP editor reports errors.

Link to comment
Share on other sites

Ok, i'll see if I can clarify.

 

The results of the query are displayed in HTML via echo. In that block of HTML code I have a 5 star rating system i'd like to include in there that, in itself, uses an 'include' statement to call it (the one I posted in previous response). However, that include statement also includes the <? ?> tags and an additional 'echo' statement. Assuming I don't need either of those since that entire block is already being echoed, what changes would I make to that tag in order for it to summon in that location? Make sense?

 

This may help. It's the instructions from their download:

 

The tags that MUST appear on your page(s) are as follows:

 

<? include("includes/rating_functions.php"); ?>

<link href="css/rating_style.css" rel="stylesheet" type="text/css" media="all">

<script type="text/javascript" src="js/rating_update.js"></script>

 

Now to call the rating bar we simply insert this PHP snippet.

 

<? echo pullRating(35,false,false,false,NULL); ?>

 

1) 35 would be your unique rating id (usually people put $_GET['id'] in there)

Link to comment
Share on other sites

*if you save your data as html in some case it will not recognize the php tags and print that as it was

*you can try saving your images as image having one star image 2 having 2 star then echo that as

<img src="$onestar"/>

*or count the point and call the images in a loop  to get all the needed stars (bad idea)

hope that helps

Link to comment
Share on other sites

Or, I could do it like this where I separate the echo statement:

 

echo "<h3>The following lenders meet your search criteria.</h3><br>\n";
// create display of results in abbreviated format
while ($row = mysql_fetch_array($results)) {
	echo "<table width='550' border='0'>
	<tr colspan='2'><td class='lendertitle'>".$row['company_name']."</td></tr>
	<tr><td class='lenderdesc'>Company phone: ".$row['company_phone']."</td></tr>
	<tr><td>Company contact: ".$row['company_contact']."</td><td><a class='lenderlink' href='loanrequest.php?lenderid=".$row['member_id'].">Submit Loan Request</a></td></tr><tr><td>";

	echo pullRating(35,false,false,false,NULL);
	echo "</td></tr></table><br />\n ";
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.