Want to make 3 Columns from my results..

06-16-03, 02:53 PM
|
|
Newbie Coder
|
|
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
Want to make 3 Columns from my results..
With this code, I get an error. Look at http://www.localwebadvertising.com/local/2/us
Parse error: parse error, unexpected T_STRING, expecting ']' in /home/localweb/public_html/include/country.inc on line 30
Line 30 is echo "<td>$array[$i + $div_point]</td>";
Any idea what I am doing wrong?
|

06-16-03, 03:07 PM
|
 |
Guru Programmer
|
|
Join Date: Jun 2003
Location: USA
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
will work. 
|

06-16-03, 03:19 PM
|
|
Newbie Coder
|
|
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I got these errors when I changed it...
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/localweb/public_html/include/country.inc on line 14
Warning: sort() expects parameter 1 to be array, null given in /home/localweb/public_html/include/country.inc on line 21
I want to go to
|

06-16-03, 04:00 PM
|
 |
Guru Programmer
|
|
Join Date: Jun 2003
Location: USA
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Yes, of course.
"SELECT DISTINCT state * FROM notable"
is invalid query. May be remove * from it. 
|

06-16-03, 04:35 PM
|
|
Newbie Coder
|
|
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
ok. here is what I am trying to do.
Here is the mysql table info (will not add as many entries)
I want a result output of all the states alphabetically sorted in three columns.
This would result in something like ...
Last edited by cebuy; 06-16-03 at 04:40 PM.
|

06-17-03, 12:40 AM
|
|
Hot Moderator ;)
|
|
Join Date: Jun 2003
Location: India
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/localweb/public_html/include/country.inc on line 14
Warning: sort() expects parameter 1 to be array, null given in /home/localweb/public_html/include/country.inc on line 21
I want to go to
|
Means your query failed.
Try
SELECT DISTINCT state FROM table_name
Also, always make sure whether your query executed or not.
Do it like,
$query = 'your query goes here.';
$result = @mysql_query($query) or die('Can not execute query : ' . $query . "\n" . 'MySQL Said : '. mysql_error());
So if your query fails, it will tell you the query and why it failed.
Regards,
JD
__________________
http://www.phpkid.org
|

06-20-03, 04:46 AM
|
 |
Newbie Coder
|
|
Join Date: Jun 2003
Location: Indonesia
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
THIS IS THE ALGORITHM FOR MAKING THREE COLUMN RESULT
But You could change the looping control structure
with mysql query.
<?
echo "<h3>ORIGINAL DATA </h3>";
$state=array("0","GA","SC","AL","MS","OR","FL","OR ","TN","CA");
for ($i=1;$i<count($state);$i++){
echo $state[$i]." . ";
}
sort ($state);
echo "<hr>";
echo "<h3>DISPLAYING HORISONTAL SORT </h3>";
echo "<table border=1><tr>";
for ($i=1;$i<count($state);$i++){
echo "<td><li>".$state[$i]."</td>";
if (($i % 3)==0){ echo "</tr><tr>"; }
}
echo "</tr></table>";
echo "<hr>";
echo "<h3>DISPLAYING VERTICAL SORT</h3>";
echo "<table border=1><tr><td>";
for ($i=1;$i<count($state);$i++){
echo "<li>".$state[$i]."</li>";
if (($i % 3)==0){ echo "</td><td>"; }
}
echo "</td></tr></table>";
?>
__________________
-=ridwank=-
<b><a style='text-decoration:none' href="http://www.ridwank.com">CLICK : ridwank.com : PHP SCRIPT CENTER</a></b>
Last edited by ridwank; 06-20-03 at 05:19 AM.
|

06-20-03, 08:43 AM
|
|
The Freshmaker
|
|
Join Date: Jun 2003
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
This might help make your life easier when it comes to working with mySQL:
http://www.hotscripts.com/Detailed/18290.html
Cheers,
Justin 
|

06-20-03, 10:17 AM
|
|
Newbie Coder
|
|
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
THanks I will look into that.
|

06-20-03, 12:49 PM
|
 |
Newbie Coder
|
|
Join Date: Jun 2003
Location: FL
Posts: 75
Thanks: 0
Thanked 1 Time in 1 Post
|
|
I'm currently using this for a larger project, and it works wonders.
No, I'm not affiliated with them I just like using it.
__________________
Nothing witty...
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|