Jump to content

Manage Query Externally By Way of a Variable


e1seix

Recommended Posts

I think this is a pretty stupid question, but I have tried to search online for an answer and I'm not quite sure what I'm asking for.

 

I'm talking about the premise of including a sort of configuration page so I can use the same basic template of a product page but change the actual query itself by defining it as a variable. Something along the lines of:

 

$qqq='SELECT * FROM products WHERE forSale='yes' AND inStock='yes' AND sub LIKE '%$sub%' ORDER BY brand,name LIMIT $startrow, $limit';

// START OF RESULTS QUERY
$qryResults=mysql_query( $qqq )or die(mysql_error());
while($row = mysql_fetch_array( $qryResults )) {

 

You see?

 

Any help appreciated!

I'm assuming you HAVE this template available, your sort of "Product" template.. in which case, you could just do something like

<?php

  // do your mysql query w\e here...

  if ($row = mysql_fetch_assoc($query)) {

    // dw about this.. put all the $row['field_names'] where they belong in the template

  } else { include("error.php"); die(); }

?>

<div><?php echo $row['product_name']; ?></div>

 

Archived

This topic is now archived and is closed to further replies.

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