Jump to content

Create a List from a Recordset


piskie

Recommended Posts

I need to produce a list of All the different "Makes" in a Temporary Recordset. Each "Make" will apear a number of times in the Recordset but I only want each make to appear in the list once. Can anybody guide me to how I can achieve this please. I have pasted (basic) code below. I would very much prefer it to be achieved in the In Body Code only if possible.

 

List Item "Repeat Region" code:

<?php do { ?>
<li><?php echo $row_LISTMAKES['make']; ?></li>
<?php } while ($row_LISTMAKES = mysql_fetch_assoc($LISTMAKES)); ?>

 

Temporary Recordset produced by:

<?php require_once('Connections/WEBSITE.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$colname_LISTMAKES = "-1";
if (isset($_GET['100'])) {
  $colname_LISTMAKES = (get_magic_quotes_gpc()) ? $_GET['100'] : addslashes($_GET['100']);
}
mysql_select_db($database_WEBSITE, $WEBSITE);
$query_LISTMAKES = sprintf("SELECT * FROM DEALERS WHERE reference = %s ORDER BY make ASC", GetSQLValueString($colname_LISTMAKES, "int"));
$LISTMAKES = mysql_query($query_LISTMAKES, $WEBSITE) or die(mysql_error());
$row_LISTMAKES = mysql_fetch_assoc($LISTMAKES);
$totalRows_LISTMAKES = mysql_num_rows($LISTMAKES);
?>

Link to comment
https://forums.phpfreaks.com/topic/60180-create-a-list-from-a-recordset/
Share on other sites

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.