Current location: Hot Scripts Forums » Programming Languages » PHP » multidimentional msql_fetch_array

multidimentional msql_fetch_array

Reply
  #1 (permalink)  
Old 08-19-08, 02:33 PM
snakeob snakeob is offline
Newbie Coder
 
Join Date: Jun 2008
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
multidimentional msql_fetch_array

PHP Code:
<?php

$query 
mysql_query("SELECT * FROM biller");
while (
$result mysql_fetch_array($query))
    {
        
$query2 mysql_query("SELECT * FROM biller WHERE account LIKE ($_POST[number])");
        while (
$result2 mysql_fetch_array($query2))
        {
            
$query3 mysql_query("SELECT * FROM biller WHERE calldate LIKE '%($_POST[month])%'");
            while (
$result3 mysql_fetch_array($query3))
            {
                
$query4 mysql_query("SELECT * FROM biller WHERE calldate LIKE '%($_POST[year])%'");
                while (
$row mysql_fetch_array($result4MYSQL_ASSOC))
{
    
$account=$row['account'];
    
$calldend=$row['calldateend'];
    
$calldstart=$row['calldatestart'];
    
$calldate=$row['calldate'];
    
$totalctime=$row['totalcalltime'];
    
$totalccharge=$row['totalcallcharge'];
    
$charge=$row['charge'];
    
$origin=$row['origin'];
    
$navi=$row['navigataid'];

print 
"<tr>
    <td>$account</td>
    <td>$calldend</td>
    <td>$calldstart</td>
    <td>$calldate</td>
    <td>$totalctime</td>
    <td>$totalccharge</td>
    <td>$charge</td>
    <td>$origin</td>
    <td>$navi</td>
</tr>"
;
}}}
}
?>

nothing prints on my table what am i doin wrong??
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 08-19-08, 04:33 PM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,029
Thanks: 14
Thanked 34 Times in 33 Posts
Quote:
Originally Posted by snakeob View Post
nothing prints on my table what am i doin wrong??
Maybe it's just me, but I don't see a <table> definition. I see a table row and cells, but no actual table tag.
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data (scroll down)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 08-20-08, 08:54 AM
snakeob snakeob is offline
Newbie Coder
 
Join Date: Jun 2008
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
its above, i dint include that portion of the code
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 08-20-08, 09:31 AM
<?Wille?> <?Wille?> is offline
Junior Code Guru
 
Join Date: Jan 2004
Location: Helsinki, Finland
Posts: 666
Thanks: 0
Thanked 0 Times in 0 Posts
$result4 should be $query4?

$query4 = mysql_query("SELECT * FROM biller WHERE calldate LIKE '%($_POST[year])%'");
while (
$row = mysql_fetch_array($result4, MYSQL_ASSOC))
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 08-20-08, 11:02 AM
snakeob snakeob is offline
Newbie Coder
 
Join Date: Jun 2008
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
see below for updated code i need helllp

Last edited by snakeob; 08-20-08 at 11:26 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 08-20-08, 11:25 AM
snakeob snakeob is offline
Newbie Coder
 
Join Date: Jun 2008
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Code:
<?php
session_start
();
if(!isset(
$_SESSION['username']) || !isset($_SESSION['sid']) ||!isset($_SESSION['ip'])) {
header("Location: login.php");
exit;
}
echo 
"Welcome, " $_SESSION['username'] . "<br>";
echo 
"You can only access this page if you are logged in.";
?>
        

<html>
<head><title>1800billing</title></head>
<body>
        <center>
<h1>This is the 1800billing site</h1>
                </center>    
<?php
echo "The Client Billed Is: ",var_export($_POST[number])," for "var_export($_POST[month]), var_export($_POST[year]);
$DB "jakestest";
$link mysql_connect("localhost","root","")
        or die(
"cant connect");
mysql_select_db($DB);
?>

<table border=1 width=100% height=5>
<tr>
    <th>Account</th>
    <th>Call End</th>
    <th>Call Start</th>
    <th>Call Log</th>
    <th>Call Length</th>
    <th>Call Rate</th>
    <th>Call Charge</th>
    <th>Call Location</th>
    <th>Navi ID</th>
</tr>

<?php

$query 
mysql_query("SELECT * FROM biller");
while (
$result mysql_fetch_array($query))
    {
        
$query2 mysql_query("SELECT * FROM biller WHERE account LIKE ($_POST[number])");
        while (
$result2 mysql_fetch_array($query2))
        {
            
$query3 mysql_query("SELECT * FROM biller WHERE calldate LIKE '%($_POST[month])%'");
            while (
$result3 mysql_fetch_array($query3))
            {
                
$query4 mysql_query("SELECT * FROM biller WHERE calldate LIKE '%($_POST[year])%'");
                while (
$row mysql_fetch_array($query4MYSQL_ASSOC))
                {
    
$account=$row['account'];
    
$calldend=$row['calldateend'];
    
$calldstart=$row['calldatestart'];
    
$calldate=$row['calldate'];
    
$totalctime=$row['totalcalltime'];
    
$totalccharge=$row['totalcallcharge'];
    
$charge=$row['charge'];
    
$origin=$row['origin'];
    
$navi=$row['navigataid'];

print 
"<tr>
    <td>$account</td>
    <td>$calldend</td>
    <td>$calldstart</td>
    <td>$calldate</td>
    <td>$totalctime</td>
    <td>$totalccharge</td>
    <td>$charge</td>
    <td>$origin</td>
    <td>$navi</td>
</tr>"
;
}}}
}
?>

<?php
echo "<table>";
echo 
$_SESSION['username'] . " would you like to send this email to, " $_SESSION['email'];
echo 
"<form action='emailconfirm.php' method ='POST'>
<tr><td><p><input type='submit' value='Send E-mail'></p></td></tr>
</form>"
;
echo 
"</table>";
?>

</table>
</body>
</html>

nothing prints on my table please help me.....

this is supposed to get the clients the months and the year

help me pleeeeeease
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 08-21-08, 12:26 AM
<?Wille?> <?Wille?> is offline
Junior Code Guru
 
Join Date: Jan 2004
Location: Helsinki, Finland
Posts: 666
Thanks: 0
Thanked 0 Times in 0 Posts
Would it not be easyer to just go with a query like this?
PHP Code:
$query mysql_query("SELECT * FROM biller WHERE account LIKE ($_POST[number]) AND calldate LIKE '%($_POST[month])%' AND calldate LIKE '%($_POST[year])%'"); 
took out all the database parts and tested it locally, prints a table just fine. so the problem is probably that your not finding anything in the database.

You can select COUNT(*) or use mysql_num_rows() to find out how many matches you got. COUNT(*) is faster if there are alot of them

btw, the query where you use $_POST[number] as a argument. Your saying to mysql that your looking for something similar, but not specifying any wildcard ( the % sign).
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 08-21-08, 04:01 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community VIP
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 2,724
Thanks: 0
Thanked 0 Times in 0 Posts
since nothing is getting outputted in your table it either means an error occured in one of your queries, or an error occured during the parsing of the php page (when the display_errors settings is off).

Add this line at the end of each mysql_query call, and tell us what you see:
PHP Code:
 or die (mysql_error ()); 
make sure you remove the ; at the end of the line first.

Place this code snippet on top of the page:
PHP Code:
error_reporting (E_ALL E_STRICT); // remove the "| E_STRICT" part when your php version is 5-
ini_set ('display_errors'1); 
Now you should get a clear error-output when an error occures. If still nothing is printed, there's probably something wrong in your query that's causing the database to select not a single row (no error, just a logical error).
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

If you want to add me on any IM, pm me first
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 08-21-08, 09:12 AM
snakeob snakeob is offline
Newbie Coder
 
Join Date: Jun 2008
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
i added
PHP Code:
$query mysql_query("SELECT * FROM biller WHERE account LIKE ($_POST[number]) AND calldate LIKE '%($_POST[month])%' AND calldate LIKE '%($_POST[year])%'"); 
and i get stuff in my table now!
my only problem is that now my logic is ignoring my two calldate querys

basicly you have a selection of account, month, and year
my account seems to be working fine.

im using the $_POST[month] as a way of selecting the month and year for year from a different database so that i dont get any jiberish from the mysql data, and trying to search using what you have selected from previous.

mysql> SELECT * FROM biller WHERE account LIKE 8669605227 AND calldate LIKE '%Feb%';

if i type this into mysql it works fine, i just cant seem to get these $_POST to work
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #10 (permalink)  
Old 08-21-08, 10:17 AM
snakeob snakeob is offline
Newbie Coder
 
Join Date: Jun 2008
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
i took the line completely out and it querys i realized it must be querying from my first page which follows,

PHP Code:
<?php

##                                ##
#this part connects to the database#
##                                ##

$DB "jakestest";

$link mysql_connect("localhost","root","")
        or die(
"cant connect");

mysql_select_db($DB);

##                                                           ## 
#this part is a combonation of bill, month and year selectionn#
##                                                           ## 

echo "<h2>Please select the client, month and year that you  would like to generate a bill for<h2>";
echo 
"<form action='processform.php' method='POST'>";
echo 
"<select name=number>\n";
$result mysql_query("SELECT DISTINCT account FROM biller");
    while (
$row mysql_fetch_array($result))
{
    echo 
"<option value='{$row['account']}'>";
    echo 
$row['account']."\n";
}
echo 
"</select>";

echo 
"\t";

echo 
"<select name=month>\n";
$result2 mysql_query("SELECT DISTINCT months FROM months");
while ( 
$row mysql_fetch_array($result2))
{
        echo 
"<option value='{$row['months']}'>";
        echo 
$row['months'] ."\n";
}
echo 
"</select>";

echo 
"\t";

echo 
"<select name=year>\n";
$result3 mysql_query("SELECT DISTINCT years FROM years");
while ( 
$row mysql_fetch_array($result3))
{
        echo 
"<option value='{$row['years']}'>";
    echo 
$row['years']."\n";
}
echo 
"</select>";

echo 
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp";
echo 
"\n<input type='submit' value= 'Submit'>";
echo 
"\n</form>\n";
echo 
"</option>"
?>
</center>
</body>
</html>
because im querying from a different table to make the month and year dropdown list clean, but it is not getting from my big table, how do i combine them now??
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 07:04 PM.
vBulletin® Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.