User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 455,985 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,759 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1080 | Replies: 30
Reply
Join Date: Jan 2008
Posts: 78
Reputation: rickarro is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
rickarro rickarro is offline Offline
Junior Poster in Training

Re: shorting problem

  #11  
May 20th, 2008
I'm assuming you are wanting me to check my error reporting. Whether I have it on or off, I don't get data presented from the database, just the errors with the headers(reporting on), or just the headers (reporting off).

What am I not seeing here?

thanks.
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: shorting problem

  #12  
May 20th, 2008
Well, notices can be ignored. But if you want to get rid of notices without disabling it, initialize every variable before using it. Here is an example.
  1. <?php
  2. error_reporting(E_ALL);
  3. $arr = array();
  4. echo $arr['1'];
  5. ?>
This will generate the notice undefined index since $arr['1'] doesn't have any value and isn't initialized where as, this wouldn't generate any notice.
  1. <?php
  2. error_reporting(E_ALL);
  3. $arr = array();
  4. $arr['1']="";
  5. echo $arr['1'];
  6. ?>
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Jan 2008
Posts: 78
Reputation: rickarro is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
rickarro rickarro is offline Offline
Junior Poster in Training

Re: shorting problem

  #13  
May 20th, 2008
Ok, I'm still playing with it and have gotten the data to display. When I click on my column headings to sort by that heading, I get a "page can not be found" error.
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: shorting problem

  #14  
May 20th, 2008
Dude! check the hyperlink.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Jan 2008
Posts: 78
Reputation: rickarro is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
rickarro rickarro is offline Offline
Junior Poster in Training

Re: shorting problem

  #15  
May 20th, 2008
I was able to get my data by using $row instead of col, would the sorting work better using row instead of column? Heres the code I've used so far:
<?php

$host = "localhost";
$user = "root";
$pass = "xx";
$db = "phonebook";
// create query
$conn=mysql_connect($host,$user,$pass);

mysql_select_db($db);

if(isset($_GET['col']) && isset($_GET['order'])) {
$column=$_GET['col'];
$order=$_REQUEST['order'];

if($column == "fname"){
	if($order=="asc"){ $order="desc"; } else {
	$order="asc"; }
	$value1="?col=fname&order=$order";
	$query="select * from people order by $column $order";
}
if($column == "lname"){
	if($order=="asc"){ $order="desc"; } else {
	$order="asc"; }
	$value2="?col=lname&order=$order";
	$query="select * from people order by $column $order";
}
if($column == "phone_num"){
	if($order=="asc"){ $order="desc"; } else {
	$order="asc"; }
	$value3="?col=phone_num&order=$order";
	$query="select * from people order by $column $order";
}
if($column == "ext"){
	if($order=="asc"){ $order="desc"; } else {
	$order="asc"; }
	$value4="?col=ext&order=$order";
	$query="select * from people order by $column $order";
}
if($column == "title"){
	if($order=="asc"){ $order="desc"; } else {
	$order="asc"; }
	$value5="?col=title&order=$order";
	$query="select * from people order by $column $order";
}
if($column == "dept"){
	if($order=="asc"){ $order="desc"; } else {
	$order="asc"; }
	$value6="?col=dept&order=$order";
	$query="select * from orders order by $column $order";
}
if($column == "fax"){
	if($order=="asc"){ $order="desc"; } else {
	$order="asc"; }
	$value7="?col=fax&order=$order";
	$query="select * from people order by $column $order";
}

} else {
	
	$value1="?col=fname&order=asc";
	$value2="?col=lname&order=asc";
	$value3="?col=phone_num&order=asc";
	$value4="?col=ext&order=asc";
	$value5="?col=title&order=asc";
	$value6="?col=dept&order=asc";
	$value7="?col=fax&order=asc";
	$query="select * from people";
	
}

$result=mysql_query($query);

?>

<html>
<body>
<table border=1>
<th><a href="sort.php<?php echo $value1 ?>">First Name</th>
<th><a href="sort.php<?php echo $value2 ?>">Last Name</th>
<th><a href="sort.php<?php echo $value3 ?>">Phone Number</th>
<th><a href="sort.php<?php echo $value4 ?>">Extension</th>
<th><a href="sort.php<?php echo $value5 ?>">Title</th>
<th><a href="sort.php<?php echo $value6 ?>">Department</th>
<th><a href="sort.php<?php echo $value7 ?>">Fax Number</th>
</table>

</body>
</html>

<?php

while($row = mysql_fetch_row($result)) {
	 	echo "<table cellpadding=10 border=0>";
	    echo "<tr>"; 
        echo "<td><font size='2'>".$row[1]."</td>"; 
        echo "<td><font size='2'>".$row[2]."</td>"; 
        echo "<td><font size='2'>".$row[3]."</td>";
        echo "<td><font size='2'>".$row[4]."</td>";
        echo "<td><font size='2'>".$row[5]."</td>";
        echo "<td><font size='2'>".$row[6]."</td>";
        echo "<td><font size='2'>".$row[7]."</td>";
        
        echo "</tr>";
}		
echo "</table>";

?>

I may be way off but if my $value was based on $row instead of ?col would I get a better result? My while statement worked with the $row statement. The hyperlink looks ok to me.
Last edited by rickarro : May 20th, 2008 at 12:13 pm.
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: shorting problem

  #16  
May 20th, 2008
umm.. col is the column name which you want to sort.. Is it working for you ?
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Jan 2008
Posts: 78
Reputation: rickarro is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
rickarro rickarro is offline Offline
Junior Poster in Training

Re: shorting problem

  #17  
May 20th, 2008
Originally Posted by nav33n View Post
umm.. col is the column name which you want to sort.. Is it working for you ?



No its not working for me. I'm still getting a "page can not be found" error.
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: shorting problem

  #18  
May 20th, 2008
What have you named this script ? Is it called sort.php ?
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Jan 2008
Posts: 78
Reputation: rickarro is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
rickarro rickarro is offline Offline
Junior Poster in Training

Re: shorting problem

  #19  
May 20th, 2008
Originally Posted by nav33n View Post
What have you named this script ? Is it called sort.php ?


Ultimately it will be called "dbphone.php" but right now it is "dbphone_new.php" because its under construction
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: shorting problem

  #20  
May 20th, 2008
Then the links should be dbphone_new.php in all these cases.
<th><a href="sort.php<?php echo $value1 ?>">First Name</th>
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 9:28 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC