Jump to content

problem on my codes


pixeltrace

Recommended Posts

guys,

 

i need help.

i have a page view.php

i have a pagina working already before on this page

until i placed a drop down menu that will sort the items on the table

via

name, client id, joined date, reg date, etc

 

i tried the drop down codes without the pagina first

and it worked.

 

now when i combined the two functions i am getting some errors.

below is the error

 

============

Notice: Undefined variable: sort in c:\hosting\webhost4life\member\diorgrace\admean\client\view.php on line 10

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\hosting\webhost4life\member\diorgrace\admean\client\my_pagina_class.php on line 90

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\hosting\webhost4life\member\diorgrace\admean\client\my_pagina_class.php on line 63

 

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in c:\hosting\webhost4life\member\diorgrace\admean\client\my_pagina_class.php on line 68

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\hosting\webhost4life\member\diorgrace\admean\client\my_pagina_class.php on line 63

 

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in c:\hosting\webhost4life\member\diorgrace\admean\client\my_pagina_class.php on line 68

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\hosting\webhost4life\member\diorgrace\admean\client\my_pagina_class.php on line 63

 

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in c:\hosting\webhost4life\member\diorgrace\admean\client\my_pagina_class.php on line 68

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\hosting\webhost4life\member\diorgrace\admean\client\my_pagina_class.php on line 63

 

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in c:\hosting\webhost4life\member\diorgrace\admean\client\my_pagina_class.php on line 68

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\hosting\webhost4life\member\diorgrace\admean\client\my_pagina_class.php on line 63

 

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in c:\hosting\webhost4life\member\diorgrace\admean\client\my_pagina_class.php on line 68

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\hosting\webhost4life\member\diorgrace\admean\client\my_pagina_class.php on line 63

 

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in c:\hosting\webhost4life\member\diorgrace\admean\client\my_pagina_class.php on line 68

=====================================

 

this is my codes for the drop down menu without the pagina

<table width="100" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><img src="../images/spacer.gif" width="6" height="10"></td>
    <td><table width="216" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td colspan="3" valign="top" bgcolor="#3261BB"><img src="images/spacer.gif" width="1" height="1"></td>
      </tr>
      <tr>
        <td align="left" bgcolor="#3261BB" width="1"><img src="images/spacer.gif" width="1" height="1"></td>
        <td width="214" valign="top"><table width="794" border="0" cellspacing="2" cellpadding="0">
            <tr>
              <td colspan="6"><table width="616" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="329" class="text6">
				  total record found :					  </td>
                    <td width="287"> </td>
                  </tr>
              </table></td>
            </tr>
            <tr>
              <td colspan="6"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="459"> </td>
                    <td width="158" class="text6">sort by :
<select name="sortby" onFocus="selectedIndex = 0" onChange="if( options[selectedIndex].value != '') document.location = options[selectedIndex].value" class="sorteventlist">
                          <option value="clientmngr.php">--Please Select--</option>
					  <option value="clientmngr.php?id=2&type=1" <?=($_GET['type']==1)?"selected":"" ?>>name</option>
                          <option value="clientmngr.php?id=2&type=2" <?=($_GET['type']==2)?"selected":"" ?>>client ID</option>
                          <option value="clientmngr.php?id=2&type=3" <?=($_GET['type']==3)?"selected":"" ?>>reg date</option>
					  <option value="clientmngr.php?id=2&type=4" <?=($_GET['type']==4)?"selected":"" ?>>joined date</option>
                        </select>
                    </td>
                  </tr>
              </table></td>
            </tr>
            <tr>
              	<td colspan="6"> </td>
            </tr>
            <tr>
              <td width="58" align="center" bgcolor="#83C2ED" class="text5">ID</td>
              <td width="215" align="center" valign="top" bgcolor="#83C2ED" class="text5">name</td>
              <td width="91" align="center" bgcolor="#83C2ED" class="text5">joined date </td>
              <td width="200" align="center" bgcolor="#83C2ED" class="text5">rate agreed </td>
              <td width="175" align="center" bgcolor="#83C2ED" class="text5">remark</td>
              <td width="41" bgcolor="#83C2ED"> </td>
            </tr>
							<?
				$type = (!empty($_GET['type']))?$_GET['type']:1;
				 {
				$order=array(1=>'client_name',2=>'clientid',3=>'staff_created',4=>'staff_created');
				if (!empty($type)) $sort="ORDER by '".$order[$type]."'";
				} ?>


            <?
include 'db_connect.php';
$uSql = "SELECT clientid, client_name, day_joined, month_joined, year_joined, client_rate, client_remarks FROM clients ".$sort." ASC";
$uResult = mysql_query($uSql, $connection);

if(!$uResult){
    echo 'no data found';
} else {   	
while($uRow = mysql_fetch_row($uResult)){	
?>
            <tr>
              <td bgcolor="#FFFFCC" class="text8"> C 
                <?= $uRow[0]?></td>
              <td bgcolor="#FFFFCC" class="text8"> 
                  <?= $uRow[1]?></td>
              <td bgcolor="#FFFFCC" class="text8"> 
                  <?= $uRow[2]?>
                -
                <?= $uRow[3]?>
                -
                <?= $uRow[4]?></td>
              <td bgcolor="#FFFFCC" class="text8"> 
                  <?= $uRow[5]?></td>
              <td bgcolor="#FFFFCC" class="text8"> 
                  <?= $uRow[6]?></td>
              <td align="center" bgcolor="#FFFFCC"><a href="clientedit.php?$clientid=$clientid" class="link1">edit</a></td>
            </tr>
     <?        
}
} 
?>
            <tr>
              <td colspan="6"> </td>
            </tr>
            <tr>
              <td colspan="6"> </td>
            </tr>
        </table></td>
        <td align="right" bgcolor="#3261BB" width="1"><img src="images/spacer.gif" width="1" height="1"></td>
      </tr>
      <tr>
        <td colspan="3" valign="top" bgcolor="#3261BB"><img src="images/spacer.gif" width="1" height="1"></td>
      </tr>
    </table></td>
    <td><img src="../images/spacer.gif" width="6" height="10"></td>
  </tr>
</table>

 

and this is my code for the combined pagina and drop down menu codes

<?php
session_start();

if (session_is_registered("username")){

include($_SERVER['DOCUMENT_ROOT']."/admean/client/my_pagina_class.php");

$test = new JHpage;

$test->sql = "SELECT * FROM clients ".$sort." ASC"; // the (basic) sql statement (use the SQL whatever you like)
$result = $test->get_page_result(); // result set
$num_rows = $test->get_page_num_rows(); // number of records in result set 
$nav_links = $test->navigation(" | ", "currentStyle"); // the navigation links (define a CSS class selector for the current link)
$nav_info = $test->page_info(); // information about the number of records on page ("to" is the text between the number)
$simple_nav_links = $test->back_forward_link(true); // the navigation with only the back and forward links, use true to use images
$total_recs = $test->get_total_rows(); // the total number of records

?>

<table width="100" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><img src="../images/spacer.gif" width="6" height="10"></td>
    <td><table width="216" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td colspan="3" valign="top" bgcolor="#3261BB"><img src="images/spacer.gif" width="1" height="1"></td>
      </tr>
      <tr>
        <td align="left" bgcolor="#3261BB" width="1"><img src="images/spacer.gif" width="1" height="1"></td>
        <td width="214" valign="top"><table width="929" border="0" cellspacing="2" cellpadding="0">
            <tr>
              <td colspan="6"><table width="616" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="329" class="text6">
				<?php
				 echo "total record found:" .$total_recs; ?></td>
                    <td width="287"> </td>
                  </tr>
              </table></td>
            </tr>
            <tr>
              <td colspan="6"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="539"> </td>
                    <td width="239" align="right" class="text6">sort by :
<select name="sortby" onFocus="selectedIndex = 0" onChange="if( options[selectedIndex].value != '') document.location = options[selectedIndex].value" class="sorteventlist">
                          <option value="clientmngr.php">--Please Select--</option>
					  <option value="clientmngr.php?id=2&type=1" <?=($_GET['type']==1)?"selected":"" ?>>name</option>
                          <option value="clientmngr.php?id=2&type=2" <?=($_GET['type']==2)?"selected":"" ?>>client ID</option>
                          <option value="clientmngr.php?id=2&type=3" <?=($_GET['type']==3)?"selected":"" ?>>reg date</option>
					  <option value="clientmngr.php?id=2&type=4" <?=($_GET['type']==4)?"selected":"" ?>>joined date</option>
                        </select>                    </td>
                    <td width="12" align="right" class="text6"><img src="../images/spacer.gif" width="12" height="10"></td>
                  </tr>
              </table></td>
            </tr>
            <tr>
              	<td colspan="6"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="60%"> </td>
                    <td width="39%" align="right"><!-- nav top -->
                        <?
				echo "<span class='link1'>".$nav_links."</span>";
				?>                    </td>
                    <td width="1%" align="right"><img src="../images/spacer.gif" width="12" height="10" /></td>
                  </tr>
                </table></td>
            </tr>
            <tr>
              <td width="63" align="center" bgcolor="#83C2ED" class="text5">ID</td>
              <td width="283" align="center" valign="top" bgcolor="#83C2ED" class="text5">name</td>
              <td width="93" align="center" bgcolor="#83C2ED" class="text5">joined date </td>
              <td width="236" align="center" bgcolor="#83C2ED" class="text5">rate agreed </td>
              <td width="194" align="center" bgcolor="#83C2ED" class="text5">remark</td>
              <td width="46" bgcolor="#83C2ED"> </td>
            </tr>
							<?
				$type = (!empty($_GET['type']))?$_GET['type']:1;
				 {
				$order=array(1=>'client_name',2=>'clientid',3=>'staff_created',4=>'staff_created');
				if (!empty($type)) $sort="ORDER by '".$order[$type]."'";
				} ?>


<?php 

for ($i = 0; $i < $num_rows; $i++) {
$clientid = mysql_result($result, $i, "clientid");
$client_name = mysql_result($result, $i, "client_name");
$day_joined = mysql_result($result, $i, "day_joined");
$month_joined = mysql_result($result, $i, "month_joined");
$year_joined = mysql_result($result, $i, "year_joined");
$client_rate = mysql_result($result, $i, "client_rate");
$client_remarks = mysql_result($result, $i, "client_remarks");
?>
            <tr>
              <td bgcolor="#FFFFCC" class="text8"> C 
                <? echo ($clientid <= 9) ? " ".$clientid : $clientid;?></td>
			</td><td bgcolor="#FFFFCC" class="text8"> 
                <? echo "$client_name";?>
			</td><td bgcolor="#FFFFCC" class="text8"> 
                 <? echo "$day_joined";?>
                -
                <? echo "$month_joined";?>
                -
                <? echo "$year_joined";?>
			</td><td bgcolor="#FFFFCC" class="text8"> 
                  <? echo "$client_rate";?>
			</td><td bgcolor="#FFFFCC" class="text8"> 
                  <? echo "$client_remarks";?>
			</td><td align="center" bgcolor="#FFFFCC"><a href="clientedit.php?clientid=$clientid" class="link1">edit</a></td>
            </tr>
            <?        
} 
?>
            <tr>
              <td colspan="6" bgcolor="#83C2ED"><span class="text6"><img src="../images/spacer.gif" width="10" height="2" /></span></td>
            </tr>
            <tr>
              <td colspan="6"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="60%"> </td>
                  <td width="39%" align="right"><!-- nav top -->
                      <?
				echo "<span class='link1'>".$nav_links."</span>";
				?>
                  </td>
                  <td width="1%" align="right"><img src="../images/spacer.gif" width="12" height="10" /></td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td colspan="6"> </td>
            </tr>
        </table></td>
        <td align="right" bgcolor="#3261BB" width="1"><img src="images/spacer.gif" width="1" height="1"></td>
      </tr>
      <tr>
        <td colspan="3" valign="top" bgcolor="#3261BB"><img src="images/spacer.gif" width="1" height="1"></td>
      </tr>
    </table></td>
    <td><img src="../images/spacer.gif" width="6" height="10"></td>
  </tr>
</table>
<? 
}else{
echo "<font face=\"Arial\">You are not authorized to access this page ... Please <a href='../index.php'>Login</a></font>";
}

?>

 

need help please!

 

thanks in advance!

Link to comment
Share on other sites

thats actually the problem that i am seeing

 

the $sort is actually in the middle of the codes

 

								<?
				$type = (!empty($_GET['type']))?$_GET['type']:1;
				 {
				$order=array(1=>'client_name',2=>'clientid',3=>'staff_created',4=>'staff_created');
				if (!empty($type)) $sort="ORDER by '".$order[$type]."'";
				} ?>

 

and i dont know how to loop it back to the sql query on top

Link to comment
Share on other sites

i placed this on top of the sql query now

$sort = 'ORDER by clientid';

 

and this is the new error message that i am getting

from the drop down menu

Notice:undefined index type in c:\hosting\webhost4life\member\diorgrace\admean\client\view.php on line 47>name

Notice:undefined index type in c:\hosting\webhost4life\member\diorgrace\admean\client\view.php on line 48>client ID

Notice:undefined index type in c:\hosting\webhost4life\member\diorgrace\admean\client\view.php on line 49>red date

Notice:undefined index type in c:\hosting\webhost4life\member\diorgrace\admean\client\view.php on line 50>joined date

 

what does this mean?

 

this is the codes for that line

 

<select name="sortby" onFocus="selectedIndex = 0" onChange="if( options[selectedIndex].value != '') document.location = options[selectedIndex].value" class="sorteventlist">
                          <option value="clientmngr.php">--Please Select--</option>
					  <option value="clientmngr.php?id=2&type=1" <?=($_GET['type']==1)?"selected":"" ?>>name</option>
                          <option value="clientmngr.php?id=2&type=2" <?=($_GET['type']==2)?"selected":"" ?>>client ID</option>
                          <option value="clientmngr.php?id=2&type=3" <?=($_GET['type']==3)?"selected":"" ?>>reg date</option>
					  <option value="clientmngr.php?id=2&type=4" <?=($_GET['type']==4)?"selected":"" ?>>joined date</option>
                        </select>

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.