Jump to content

SkyRanger

Members
  • Posts

    738
  • Joined

  • Last visited

Posts posted by SkyRanger

  1. Um, thanks Jacques for your delightful answer, guess I should have explained a little better

     

    I am trying to echo this:

    <?php
    $catquery = new WP_Query( 'cat=16&posts_per_page=1 );
    while($catquery->have_posts()) : $catquery->the_post();
    ?>
    <ul>
    <li><h3><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
    
    <ul><li><?php the_content(); ?></li>
    </ul>
    </li>
    </ul>
    

    In here

    <?php if(function_exists('stbHighlightText')) stbHighlightText(echo output here, 'warning'); ?>
    
  2. Not sure if or how I can do this properly without killing my page:

    <?php
    $catquery = new WP_Query( 'cat=16&posts_per_page=1 );
    while($catquery->have_posts()) : $catquery->the_post();
    $ourspecials = "
    <ul>
    <li><h3><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
    
    <ul><li><?php the_content(); ?></li>
    </ul>
    </li>
    </ul>"; ?>
    
    <?php if(function_exists('stbHighlightText')) stbHighlightText($ourspecials, 'warning'); ?>
    
  3. Tried to edit post.  But here is my full code that I am working with:

     

     <?php
    						$queryfa = "SELECT  * FROM faq as f1 join faqcat as f2 where f1.farea = f2.cat_id group by f1.farea order by f1.ftitle DESC";
                            $resultfa = $mysqli->query($queryfa) or die($mysqli->error.__LINE__);
    						
    
                            while($rowfa = $resultfa->fetch_assoc()){
    							
    						?>
    				<div class="grid_16">
    					<table>
    						<thead>
    							<tr>
    								<th colspan="3">FAQ - <?php echo $rowfa['cat_name']; ?></th>
    								<th colspan="2">Actions</th>
    							</tr>
    						</thead>
    						<tfoot>
    							<tr>
    								<td colspan="5" class="pagination">
    									View More
    								</td>
    							</tr>
    						</tfoot>
    						<tbody>
                               <tr>
                                   <td width="21%"><u><em><strong>Title</strong></em></u></td>
                                   <td width="50%"><u><em><strong>Description</strong></em></u></td>
                                   <td width="17%"><u><em><strong>Date Added</strong></em></u></td>
                                   <td width="6%"></td><td width="6%"></td>
                               </tr>    
    							<tr>
    								<td><?php echo $rowfa['ftitle']; ?></td>
    								<td><?php echo $rowfa['fdesc']; ?></td>
    								<td><?php echo $rowfa['posted']; ?></td>
    								<td><a href="viewfaq.php?faq=<?php echo $rows['fid']; ?>" class="edit">View</a></td>
    								<td><a href="delfaq.php?faq=<?php echo $rows['fid']; ?>" class="delete">Delete</a></td>
    							</tr>
    						<?php
    						}
                            ?>	
    						</tbody>
    					</table>
    				</div>
    			</div>
    
  4. The query that I posted will only give 1 output per farea,  There is more than 1 entry per farea

     

    So what is displaying is:

     

    cat_name1

    ftitle1  fdesc1 posted1

     

    cat_name2

    ftitle2 fdesc2 posted2

     

    cat_name3

    ftitle5 fdesc5 posted5

     

     

    but there is 

    cat_name1

    ftitle1 des...

    ftitle3 des...

     

    cat_name2

    ftitle2 .....

    ftitle4....

     

    cat_name3

    ftitle5

    etc....

  5. The problem that I am having is that it will only display 1 output for each farea.  Not sure what the problem is

     

    $queryfa = "SELECT  * FROM faq as f1 join faqcat as f2 where f1.farea = f2.cat_id group by f1.farea order by f1.ftitle DESC";
    

     

    Database layout is:

    Table: 
    faq
    
    Rows:
    farea
    ftitle
    fdesc
    posted
    
    Table:
    faqcat
    
    Rows:
    cat_id
    cat_name
    
    
    

     

     

  6. I keep receiving the error Invalid file when uploading 

     

    this is my form

    <form method="post" action="upload_imfile.php" enctype="multipart/form-data">
    <label>File to Upload:</label>
    <input type="file" name="file">
    <input type="submit" name="submit" value="Proceed with Upload">
    </form>
    
    

     

     

    $allowedExts = array("pdf", "zip", "rar");
    $extension = end(explode(".", $_FILES["file"]["name"]));
    
    if ((($_FILES["file"]["type"] == "application/pdf")
    || ($_FILES["file"]["type"] == "application/zip")
    || ($_FILES["file"]["type"] == "application/x-zip-compressed")
    || ($_FILES["file"]["type"] == "multipart/x-zip")
    || ($_FILES["file"]["type"] == "application/x-compressed")
    || ($_FILES["file"]["type"] == "application/octet-stream"))
    && ($_FILES["file"]["size"] < 20000)
    && in_array($extension, $allowedExts))
      {
      if ($_FILES["file"]["error"] > 0)
        {
        echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
        }
      else
        {
        echo "Upload: " . $_FILES["file"]["name"] . "<br>";
        echo "Type: " . $_FILES["file"]["type"] . "<br>";
        echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
        echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>";
    
        if (file_exists("clients/$client/personal/" . $_FILES["file"]["name"]))
          {
          echo $_FILES["file"]["name"] . " already exists. ";
          }
        else
          {
          move_uploaded_file($_FILES["file"]["tmp_name"],
          "clients/$client/personal/" . $_FILES["file"]["name"]);
          echo "Stored in: " . "clients/$client/personal/" . $_FILES["file"]["name"];
          }
        }
      }
    else
      {
      echo "Invalid file";
      }
    

     

     

  7. I am having problem with checking if a row exists with no errors being displayed:

     

    $queryged = "SELECT * FROM `gedcom` WHERE `client`='$loggedin' limit 1";
    $resultged = $mysqli->query($queryged) or die($mysqli->error.__LINE__);
    
    while($rowged = $resultged->fetch_assoc()){
    
    if ($rowged['client'] == 0 ) {
                echo "No";
    } else {
                echo "<a href=\"client/".$loggedin."/personal/".$rowged['ged']."\">YES</a>  Updated: ".$rowget['gedup']."";
            }    } 	
    

     

     

  8. ok, got the show only 1 record per category, forgot to use group by

     

    SELECT * 
    FROM gallery_category AS g1
    LEFT JOIN gallery_photos AS g2 ON g1.category_id = g2.photo_category
    WHERE g1.photo_owner =  '$client'
    GROUP BY category_id
    

     

    Anybody have an idea on how to show a random photo_filename for each category?

  9. Hey Psycho

     

    The problem I am having is that when the page is loaded it shows all the categories and also shows and image above the category name.  What I need it to do is show the categories and show a random image for each category.  Right now it is showing all the images for each category.  I hope that explains it some.

     

    example:

     

    table layout:

     

    table: gallery_category

     

    category_id    category_name  photo_owner

    1                          family               ownername

    2                          christmas         ownername

    3                          holiday             ownername

    4                          party                ownername

     

     

    table:  gallery_photos

     

    photo_filename   photo_category photo_owner

    image1.jpg                   2                 ownername

    image2.jpg                   2                 ownername

    image3.png                  3                ownername

    etc.....

     

    Not sure how to fix this problem and do as I need.  

     

  10. Is there a way to display a random image on page reload for each:

     

    $query = "SELECT * 
    FROM gallery_category AS g1
    LEFT JOIN gallery_photos AS g2 ON g1.category_id = g2.photo_category
    WHERE g1.photo_owner =  '$client'";
    $result = $mysqli->query($query) or die($mysqli->error.__LINE__);
    ?>
    
    
    <?php
    //Define number of columns to use
    $maxColumns  = 5;
    
    $count = 0;              //Var to count records
    $categoryList = ''; //Var to hold HTML output
    while($row = $result->fetch_assoc())
    {
            $count++; //Increment count
    
            //Open new row if first record in row
            if($count % $maxColumns == 1)
            {
                    $categoryList .= "<tr>\n";
            }
    $cid = $row['category_id'];
            //Output current record
            $categoryList .= "<td width=20%><br><center>";
    		 
              if (empty($row['photo_filename'])) {
            $categoryList .= "<img src=images/noimage.jpg height=100 width=100>";
            } else { 
    		$categoryList .= "<img src=clients/{$client}/photos/{$row['photo_filename']} height=100 width=100>";
    		}
    		$categoryList .= "<br><a class=black-text href=showphoto.php?cid=$cid>{$row['category_name']}</a></center><br></td>\n";
    
            //Close row if last record in row
            if($count % $maxColumns == 0)
            {
                    $categoryList .= "</tr>\n";
            }
    }
    
    //Close last row if needed
    if($maxColumns % $count != 0)
    {
            $categoryList .= "</tr>\n";
    }
    
    ?>
    <table width="95%" border="0">
    <?php echo $categoryList; ?>
    </table>
    

     

     

    So when 

    $categoryList .= "<img src=clients/{$client}/photos/{$row['photo_filename']} height=100 width=100>";
    

     

    gets refreshed it will display a different image.

  11. Thanks jazzman.

     

    Got it so far to upload the files, but having problems with database entry.

     

    Here is the code:

     

    $compname=$_POST['icompname'];
    $ipolicy=$_POST['polnum'];
    $itofins=$_POST['tofins'];
    $tstart=$_POST['cstart'];
    $tend=$_POST['cend'];
    $client=$_POST['member'];
    
    
    $target = "clients/$client/insurance/";
    
    
    // use static values in that case
    $itype1= basename($_FILES['photo']['name'][0]);
    $itype2= basename($_FILES['photo']['name'][1]);
    $itype3= basename($_FILES['photo']['name'][2]);
    
    
    if(!empty($_FILES['photo']['tmp_name']))
    {
    
    
            // prepare insert query statement
            $query = "INSERT INTO cinsurh VALUES ('', '$client', '$compname', '$ipolicy', '$itofins', '$tstart', '$tend', '$itype1', '$itype2', '$itype3')";
    
    
            // Number of uploaded files
            $num_files = count($_FILES['photo']['tmp_name']);
    
    
            /** loop through the array of files ***/
            for($i=0; $i < $num_files;$i++)
            {
                    // check if there is a file in the array
                    if(!is_uploaded_file($_FILES['photo']['tmp_name'][$i]))
                    {
                            $messages[] = 'No file uploaded';
                    }
                    else
                    {
                            // move the file to the specified dir
                            if(move_uploaded_file($_FILES['photo']['tmp_name'][$i],$target.'/'.$_FILES['photo']['name'][$i]))
                            {
    
                                    $messages[] = $_FILES['photo']['name'][$i].' uploaded';
    
                            }
                            else
                            {
                                    // an error message
                                    $messages[] = 'Uploading '.$_FILES['photo']['name'][$i].' Failed';
                            }
                    }
            }
    
            echo '<pre>'.print_r($query, true).'</pre>';
    
            echo '<pre>'.print_r($messages, 1).'</pre>';
    
    
            // execute query...
            $result = $mysql->query($query) or die($mysqli->error.__LINE__);
    
    }
    

     

    But I am getting this error:

    Fatal error: Call to a member function query() on a non-object in insert_policy.php on line 61
    
    This is line 61:    $result = $mysql->query($query) or die($mysqli->error.__LINE__);
    
    

  12. Can somebody point me in the right direction. I am trying to create a multi file upload script with data stored in database. I can upload single file that is not a problem. But I need to figure out how to upload multiple files.

     

    Database is:

     

    Description pdfversion picversion zipversion

     

    So the user puts in the description then added what ever version they want and it submits into the right column.

     

    So the user adds a description then wants to upload a pdf and zip version and when he submits it goes into the right columns and uploads to the directory.

     

    Any direction would be greatly appreciated.

  13. Holy Crap it worked, thank you DavidAM never thought of putting the () around them, have been fighting with this all day and that is the one thing I never tried. Yeah and the event_start sounds like a better way of doing that. Thank you.

     

    And on Note 2, That is a good idea, thank you. Will rewite the code for that.

  14. Sounds good to me, but not sure how I would go about that without screwing up the whole calendar with the 2 different $event_title outputs due to that the $event_title is the main array to create the table for events:

     

    if ($chkEvent_res->num_rows > 0) {
    $event_title = "<br/>";
    while ($ev = mysqli_fetch_array($chkEvent_res)) {
    $event_title .= "".stripslashes($ev["event_title"])."<br/>";
    }
    mysqli_free_result($chkEvent_res);
    } else {
    $event_title = "";
    }
    
           $currentm = date("n");
           $currentd = date("j");
           $currenty = date("Y");
    
           $bgc = '';  // default no bgcolor
    if ($dayArray['mday'] == $currentd) {
     $bgc = ' bgcolor="#d0e4eb"'; 
    } elseif (!empty($event_title)) {
     // Set event color
     $bgc = ' bgcolor="#b47a42"';
    }
    if ($month == $currentm && $firstDayArray['year'] == $currenty) {
           echo '<td' . $bgc . "  height=\"74\" valign=\"top\" class=\"caltd\"><center><a class=\"calnum\" href=\"javascript:eventWindow('event.php?m=".$month."&d=".$dayArray["mday"]."&y=$year');\">".$dayArray["mday"]."</a><br/>".$event_title."</center></td>\n";
    } else {
           echo "<td height=\"74\" valign=\"top\" class=\"caltd\"><center><a class=\"calnum\" href=\"javascript:eventWindow('event.php?m=".$month."&d=".$dayArray["mday"]."&y=$year');\">".$dayArray["mday"]."</a><br/>".$event_title."</center></td>\n";            
                            }
    

  15. Each client has there own calendar. The $loggedin is just the username that is pulled from the session to put against the query to pull there events out of the database. The adminpost is any event the admin posts to the clients that will show on the users calendar.

     

     

    For some reason it is the "or adminpost='All'" causing all the problems and not sure why because when I remove this the clients events show with no problems but when I put the or in the All posts show on every single day.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.