LITTLEBLACKDOG.COM Forum Index LITTLEBLACKDOG.COM

 
LWD LWD   FAQ FAQ   Memberlist Memberlist   Usergroups Usergroups   Active Topics Active Topics   Register Register  
  Profile Profile   Log in to check your private messages Log in to check your private messages   Log in Log in  
  Who is Online Who is Online   Image Gallery Image Gallery   Chat Chat   Search Search  
  LWDGear       LBDGear  

View next topic
View previous topic
Post new topic     Reply to topic   LITTLEBLACKDOG.COM Forum Index » Code Warriors
Author Message
drums
Toilet Drinker
Toilet Drinker


Joined: 19 Jun 2003
Posts: 232
Location: Portland, OR

Post Posted: Thu Oct 29, 2009 5:51 pm   Post subject: Need help pulling in data by multiple rows Reply with quote Back to top  

I have a program that updates a dB with a CSV file so all the data is imported in a straight line or row of the CSV file. Called thusly:
Code: Select all

<?
$query = mysql_query("select * from xlsdata where page='calendar'") or die("SQL error: " . mysql_error());if (FALSE === ($record = mysql_fetch_array($query))){   
} ?>

I then display the data this way (only showing 2 of 5 entry points on the page):
Code: Select all

<h2><?php echo $record['header1']; ?></h2>
<p><?php echo $record['para1']; ?>
 <blockquote>
   <?php if(!empty($record['bullet1'])) echo "<li>".$record['bullet1']."</li>"; ?>
    <?php if(!empty($record['bullet1-2'])) echo "<li>".$record['bullet1-2']."</li>"; ?>
    <?php if(!empty($record['bullet1-3'])) echo "<li>".$record['bullet1-3']."</li>"; ?>
    <?php if(!empty($record['bullet1-4'])) echo "<li>".$record['bullet1-4']."</li>"; ?>
    <?php if(!empty($record['bullet1-5'])) echo "<li>".$record['bullet1-5']."</li>"; ?>
    <?php if(!empty($record['bullet1-6'])) echo "<li>".$record['bullet1-6']."</li>"; ?>
    <?php if(!empty($record['bullet1-7'])) echo "<li>".$record['bullet1-7']."</li>"; ?>
    </blockquote>
<?php echo $record['para1-end']; ?></p>

<h2><?php echo $record['header2']; ?></h2>
<p><?php echo $record['para2']; ?>
 <blockquote>
   <?php if(!empty($record['bullet2'])) echo "<li>".$record['bullet2']."</li>"; ?>
    <?php if(!empty($record['bullet2-2'])) echo "<li>".$record['bullet2-2']."</li>"; ?>
    <?php if(!empty($record['bullet2-3'])) echo "<li>".$record['bullet2-3']."</li>"; ?>
    <?php if(!empty($record['bullet2-4'])) echo "<li>".$record['bullet2-4']."</li>"; ?>
    <?php if(!empty($record['bullet2-5'])) echo "<li>".$record['bullet2-5']."</li>"; ?>
    <?php if(!empty($record['bullet2-6'])) echo "<li>".$record['bullet2-6']."</li>"; ?>
    <?php if(!empty($record['bullet2-7'])) echo "<li>".$record['bullet2-7']."</li>"; ?>
    </blockquote>
<?php echo $record['para2-end']; ?></p>

This has worked fine as usually I make each row a page and call them that way. This time however, I just have one page that I'm updating (5 areas with 10 cells for each) and I want to make it easier for the user to fill out the spreadsheet. So I would rather that each row is one of 5 data entry points on that page. So I want the data pulled by row and column going down instead of across the same row (each header cell is uniquely named to accomplish this).
So in case I'm not being followed, visualize Row 1 is the header with A1 being the identifier, A2 data1, A3=data2 and so on to A11, then I repeat that 4 times in the same row for all the data entry cells giving me a total of 51 cells.
Instead, I would like the header row to be just that with the first the identifier column and then the 10 header cells each spot on the page will have an identifier in the rows below the header row (5 different entry points) on the page (1st - 5th). This way it is a little more visible and appealing to the user filling out this spreadsheet and since they are going to be moving things up (each event on the page has a date starting in its header) by deleting the data in the first row then moving all the others up and making a new one in the 5th row it would be easier in this format.

So I was thinking I could use AND but I don't think it will know where to put the data unless it fills top down until the EOF by nature.
Code: Select all
<?
$query = mysql_query("select * from xlsdata where placement='1st' AND placement='2nd' AND placement='3rd' AND placement='4th' AND placement='5th'") or die("SQL error: " . mysql_error());if (FALSE === ($record = mysql_fetch_array($query))){   
}
?>

So if I went this way would I have to have the query at each spot in the doc like this:
Code: Select all

<?
$query = mysql_query("select * from xlsdata where placement='1st'") or die("SQL error: " . mysql_error());if (FALSE === ($record = mysql_fetch_array($query))){   
} ?>

Code: Select all
<?
$query = mysql_query("select * from xlsdata where placement='1st'") or die("SQL error: " . mysql_error());if (FALSE === ($record = mysql_fetch_array($query))){   
} ?>

Then the data grab:
Code: Select all
<h2><?php echo $record['header1']; ?></h2>
<p><?php echo $record['para1']; ?>
 <blockquote>
   <?php if(!empty($record['bullet1'])) echo "<li>".$record['bullet1']."</li>"; ?>
    <?php if(!empty($record['bullet1-2'])) echo "<li>".$record['bullet1-2']."</li>"; ?>
    <?php if(!empty($record['bullet1-3'])) echo "<li>".$record['bullet1-3']."</li>"; ?>
    <?php if(!empty($record['bullet1-4'])) echo "<li>".$record['bullet1-4']."</li>"; ?>
    <?php if(!empty($record['bullet1-5'])) echo "<li>".$record['bullet1-5']."</li>"; ?>
    <?php if(!empty($record['bullet1-6'])) echo "<li>".$record['bullet1-6']."</li>"; ?>
    <?php if(!empty($record['bullet1-7'])) echo "<li>".$record['bullet1-7']."</li>"; ?>
    </blockquote>
<?php echo $record['para1-end']; ?></p>

Then for the next position and so on:
Code: Select all
<?
$query = mysql_query("select * from xlsdata where placement='2nd'") or die("SQL error: " . mysql_error());if (FALSE === ($record = mysql_fetch_array($query))){   
} ?>

Then the data grab:
Code: Select all
<h2><?php echo $record['header1']; ?></h2>
<p><?php echo $record['para1']; ?>
 <blockquote>
   <?php if(!empty($record['bullet1'])) echo "<li>".$record['bullet1']."</li>"; ?>
    <?php if(!empty($record['bullet1-2'])) echo "<li>".$record['bullet1-2']."</li>"; ?>
    <?php if(!empty($record['bullet1-3'])) echo "<li>".$record['bullet1-3']."</li>"; ?>
    <?php if(!empty($record['bullet1-4'])) echo "<li>".$record['bullet1-4']."</li>"; ?>
    <?php if(!empty($record['bullet1-5'])) echo "<li>".$record['bullet1-5']."</li>"; ?>
    <?php if(!empty($record['bullet1-6'])) echo "<li>".$record['bullet1-6']."</li>"; ?>
    <?php if(!empty($record['bullet1-7'])) echo "<li>".$record['bullet1-7']."</li>"; ?>
    </blockquote>
<?php echo $record['para1-end']; ?></p>

So assuming you are following what I'm trying to do, does anyone know how to accomplish this?

Thanks in advance for your time/help.

_________________
View user's profile Send private message
drums
Toilet Drinker
Toilet Drinker


Joined: 19 Jun 2003
Posts: 232
Location: Portland, OR

Post Posted: Fri Oct 30, 2009 5:28 pm   Post subject: SOLVED Reply with quote Back to top  

I figured it out. I used a query for each line and that worked.

_________________
View user's profile Send private message
fathertyme
Site Admin
Site Admin


Joined: 30 Jun 2001
Posts: 6491
Location: The American Colonies

Post Posted: Fri Oct 30, 2009 7:20 pm   Post subject: Reply with quote Back to top  

the more I glance at this, the more I think it should be:

Code: Select all
<?php echo "<li>";if(!empty($record['bullet1'])) echo $record['bullet1'];echo "</li>"; ?>

instead of:
Code: Select all
<?php if(!empty($record['bullet1'])) echo "<li>".$record['bullet1']."</li>"; ?>


the difference being that in the orignal example (shown second here), an empty field is going to throw your alignment all to hell and back since it would totally skip the field when printing out anything

example:
bullet1 = 1 bullet1-2=1
bullet2 = 2 bullet1-3=3
bullet3 = 3

would produce:

1 1
2 3
3

instead of
1 1
2
3 3

_________________
LWD web-cams: http://lwdcam.codecoma.com/?lwdcam
---
[9:08pm][09/16/2005]«+ flip » college...what is that
[9:08pm][09/16/2005]«+ Aff » apparently a place where you find rum
---
English doesn't just borrow from other languages, it follows them down dark alleys, smashes them over the head and roots around in their pockets for loose vocabulary.
---
I used to live in my own little world, but they didn't like me there either.

You see dead people? I'm a software engineer, I don't see anybody!
---
My Amazon Wishlist
---
-= Image removed because some have questioned it's appropriateness =-
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
Display posts from previous:   
Post new topic     Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
phpBB SEO
All times are GMT - 8 Hours

Help us keep advertisements off this site. Donate today!