PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old June 24th, 2003, 06:22 AM
thecharking thecharking is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 187 thecharking User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to thecharking
tables and php

okay I have a problem that I believe has to do with bad table code... but I just can't figure it out. here's the idea:

I have index.php, with many includes, one of which is called leftnav.php

I will begin by posting the code that surrounds that, and then the code for that page.

index.php
PHP Code:
<DIV style="position: absolute; top:265px; left:40px; width:0px;
 height:0; visibility: visible;" 
id="memberssection"
  <
table width="200" border="0" class="tableTop1" height="0">
 <
tr>
 <
td>
<?
php
include ('leftnav.php');
?>
</td></tr></table></div> 

leftnav.php
PHP Code:
<?php ob_start();

// Configuration part 
$dbhost "localhost"// Database host 
$dbname "users"// Database name 
$dbuser "dbuser"// Database username 
$dbpass ""// Database password 

// Connect to database 
$db mysql_connect($dbhost$dbuser$dbpass) or die("Error: Couldn't connect to database"); 
mysql_select_db($dbname$db) or die("Error: Couldn't select database.");
?>

<table width="100%" height="266" border="0">
  <tr>
    <td>
    
    <?php
    
if($IsLoggedIn)
 {
  
$levelName = @mysql_query("SELECT * FROM users WHERE username = '" $details[1] . "'");
    while (
$levelRow mysql_fetch_row($levelName))
     { 
$levelName2 $levelRow[8]; }
//echo $verifyUser;
//echo $levelName;
if(isset($_COOKIE['auth']))
    { if(
$_COOKIE['auth'] == 5)
        { echo 
"<tr><td width='100%' bgcolor='#66B4F4'>
        <center>Administrators Section</center></td></tr>"
;
            } else {
          echo 
"<tr><td width='100%' bgcolor='#66B4F4'>
          <center>Members Section</center></td><tr>"
;
            } 
          } 
         } else {
             
$levelName "Guest";
          echo 
"<tr><td width='100%' bgcolor='#66B4F4'>
          <center>Guests' Section</center></td></tr>"
;
    }
    echo 
'<tr><td><center>
    <a href="index.php?page=search">Search</a></center></td></tr>'
;
if(
$IsLoggedIn)
    { 
?>

<tr><td width='100%' bgcolor='#66B4F4'>
<center>Status : <?php echo $levelName2?></center></td></tr>
<tr><td><center><?php echo '<a href="index.php?page=viewprofile&userid=' $roomwithaview '">View Profile</a> || <a href="index.php?page=editprofile&strMethod=' $edit '">Edit Profile</a> || <a href="index.php?page=login&strMethod=logout">Log Out</a>';?></td></tr>
    <?php    
    
if (isset($_COOKIE['auth']))
        { if (
$_COOKIE['auth'] == 5)
            { 
?>
<tr><td><center><a href="index.php?page=addmovie">
Add Movie Review</a>  ||  <a href="index.php?page=viewall">
Edit Accounts</a></center></td></tr>

<?php } } } else {
?>

<tr><td width='100%' bgcolor='#66B4F4'>
<center>Status : <?php echo $levelName?></center></td></tr>

<tr><td><center>
<a href="index.php?page=registration">
Join</a> || <a href="index.php?page=login">
Login</a></center></td></tr>
        <?php }
         
?>
<tr><td width='100%' bgcolor='#66B4F4'>
<center>Recently Updated</center>
</td></tr>
<tr><td>
<?php
$updateResult 
= @mysql_query("SELECT * FROM users ORDER BY date DESC LIMIT 6");

?>

    <?php
  
        
if($updateResult)
    {
    
        while(
$updateRow mysql_fetch_array($updateResult))
        { 
            
?><tr><td><?php    
            
/*$viewNumber = @mysql_query("SELECT count(*) FROM movieviews 
                                            WHERE viewName ='" . $movieRow[2] . "'");
            $viewResult = mysql_result($viewNumber, 0, 0);*/
            
            
echo '<a href="index.php?page=viewprofile&userid='$updateRow[0] . '">
            <img src="pics/profiles/' 
$updateRow[2] . '
            /' 
$updateRow[12] . '" width="70" border="0"></a>
            <font size="1"><center>' 
$updateRow[2] . '</center></font>';
            
?></td></tr>
<?php
        
}
    }
?></td></tr>
    </td>
  </tr>
</table>


Alright so this ALMOST correct, except the pictures are seperated into what I can only assume are there own rows.

I want it to be going horizontally, but when it reaches the end of the outside of the page, after like two pics, it would jsut break and go down a row.

like this:
[pic] [pic]
name name
[pic] [pic]
name name

any ideas? thanks!
__________________
hey it's the CHARKING

Reply With Quote
  #2  
Old June 25th, 2003, 05:07 AM
_rainbow_ _rainbow_ is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Lj, Slovenia
Posts: 27 _rainbow_ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 28 sec
Reputation Power: 0
OK, if I understood you right, you only want to output two pictures in every row. You will need a counter for this. Try it this way.

PHP Code:
<?php

$_counter 
0// counter for num.pics in a row 
while($updateRow mysql_fetch_array($updateResult))
{
    if(
$_count == 0)
        echo
"<tr>"//beginning of a row
    
echo"<td><a href=\"index.php?page=viewprofile&userid=".$updateRow[0].">
    <img src=\"pics/profiles/"
.$updateRow[2]."/".$updateRow[12]."\" width=\"70\" border=\"0\"></a>
    <font size=\"1\"><center>"
.$updateRow[2]."</center></font></td>";
    
$_count++; // increment counter
    
if($_count == 2)
         {
        echo
"</tr>"// have to go to next row
                  
$_count 0// reset counter
         
}
}

?>


Hope it works the way you wanted it to.

Let me just stress that there are many errors in your script. For instance, why do you use cookies for login management. Now if I open the cookie you have set, set auth to 5 and refresh the site, I become an administrator. Better use sessions instead. You also have many errors with esaping special chars. For instance if you want to echo a " (double quote) you have to escape it with a backslash.

PHP Code:
echo"\"" //this will output " 


The same goes for single quotes and backslah (\). Hope it helps.

Last edited by _rainbow_ : June 25th, 2003 at 05:10 AM.

Reply With Quote
  #3  
Old June 25th, 2003, 04:23 PM
thecharking thecharking is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 187 thecharking User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to thecharking
thank you

Okay thanks for the help, the updated users show correctly now. Although now theother things on the side aren't spanning all the way across.

And I realize that I have many errors in my script, and I didn't want to pass any ", but thanks for telling me anyway. I probably just wrote it sort of unclearly. And about the cookies, thank you, I had been wondering about that... but now I have to figure out how to do it properly, it's probably not too hard.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > tables and php


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT