Jump to content

Recommended Posts

I have the code below:

---------------------------------------------------------------------- ------------------------------------

<div id="content">

    <table width="998" border="0" cellspacing="4" id="stuff">

        <?php do { ?>

          <tr>

            <td><?php echo $row_Recordset1['name']; ?></td>

</tr>

<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>

</table>

      <div id="spryTable" spry:region="ds1">

        <table align="center">

          <tr>

            <th spry:sort="name"> </th>

          </tr>

          <tr spry:repeat="ds1" spry:setrow="ds1" spry:hover="hover" spry:select="selected">

          <td height="40" align="center">{name}</td>  // green line

          <td height="40" align="center">{name}</td>  //orange line

          </tr>

          </table>

      </div>

---------------------------------------------------------------------- --------------------------------

At the moment the green line of code will display the entire record of names, and the orange line displays the entire record again in another column of the table.

The problem is, I want half the names to be printed in one column and the other half of names to be displayed in the other column.

Can someone show me how to set the php code to do this? I've been trying various things for a while now without success.

 

Thank you.

I have the complete code below (minus the two style sheet files). Right now the webpage will display two columns of names (lets consider one last names at the moment). The script will result in the display of two columns with the same list of names.

The problem is: I want only half the names to appear in one column (lets say from Albert to Henry) and the other half in the other column (lets say from Homer to Zebra). Does someone know how to amend this code so that it will display the names as desired?

 

CODE BELOW:

 

<?php require_once('Connections/connector.php'); ?>

<?php

if (!function_exists("GetSQLValueString")) {

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

{

  if (PHP_VERSION < 6) {

    $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;

}

}

mysql_select_db($database_connector, $connector);

$query_Recordset1 = "SELECT name FROM listings_name ORDER BY name_id ASC";

$Recordset1 = mysql_query($query_Recordset1, $connector) or die(mysql_error());

$row_Recordset1 = mysql_fetch_assoc($Recordset1);

$totalRows_Recordset1 = mysql_num_rows($Recordset1);

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Name Search</title>

<style type="text/css">

</style>

<link href="common_styles.css" rel="stylesheet" type="text/css" />

<link href="main_cols.css" rel="stylesheet" type="text/css" />

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

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

<script type="text/javascript">

var ds1 = new Spry.Data.HTMLDataSet(null, "listings_name", {firstRowAsHeaders: false, columnNames: ['name']});

ds1.setColumnType("name", "html");

</script>

</head>

 

<body>

<div id="wrapper">

    <table width="998" border="0" cellspacing="4" id="listings_name">

<?php do { ?>

          <tr>

            <td><?php echo $row_Recordset1['name']; ?></td>

</tr>

<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>

</table>

      <div id="spryTable" spry:region="ds1">

        <table align="center">

          <tr>

            <th spry:sort="name"> </th>

          </tr>

          <tr spry:repeat="ds1" spry:setrow="ds1" spry:hover="hover" spry:select="selected">

            <td height="40" align="center">{name}</td>

    <td height="40" align="center">{name}</td>

          </tr>

          </table>

      </div>

</body>

</html>

I noted the changes, and additions.  Hope it helps.

 

<?php require_once('Connections/connector.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  if (PHP_VERSION < 6) {
    $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;
}
}
mysql_select_db($database_connector, $connector);
$query_Recordset1 = "SELECT name FROM listings_name ORDER BY name_id ASC";
$Recordset1 = mysql_query($query_Recordset1, $connector) or die(mysql_error());
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Name Search</title>
<style type="text/css">
</style>
<link href="common_styles.css" rel="stylesheet" type="text/css" />
<link href="main_cols.css" rel="stylesheet" type="text/css" />
<script src="SpryAssets/SpryData.js" type="text/javascript"></script>
<script src="SpryAssets/SpryHTMLDataSet.js" type="text/javascript"></script>
<script type="text/javascript">
var ds1 = new Spry.Data.HTMLDataSet(null, "listings_name", {firstRowAsHeaders: false, columnNames: ['name']});
ds1.setColumnType("name", "html");
</script>
</head>

<body>
<div id="wrapper">
    <table width="998" border="0" cellspacing="4" id="listings_name">
<?php //changed this section to break the while loop, when half the rows have been displayed.
$half_rows = round($totalRows_Recordset1 / 2);
$i = 0;
while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)) { 
	 ?>
          <tr>
            <td><?php echo $row_Recordset1['name']; ?></td>
   </tr>
   <?php if(++$i == $half_rows) break;
   } ?>
   </table>
   
   
   <?php //This table added, Holds 2nd half of names.  I'm sure you can get it to line up right in dreamweaver. ?>
<table width="998" border="0" cellspacing="4" id="listings_name">
<?php
while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)) { ?>		
          <tr>
            <td><?php echo $row_Recordset1['name']; ?></td>
   </tr>
   <?php } ?>
   </table>
</div>



      <div id="spryTable" spry:region="ds1">
        <table align="center">
          <tr>
            <th spry:sort="name"> </th>
          </tr>
          <tr spry:repeat="ds1" spry:setrow="ds1" spry:hover="hover" spry:select="selected">
            <td height="40" align="center">{name}</td>
       <td height="40" align="center">{name}</td>
          </tr>
          </table>
      </div>
  
  
</body>
</html>

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.