Jump to content

genista

Members
  • Content Count

    149
  • Joined

  • Last visited

Community Reputation

0 Neutral

About genista

  • Rank
    Advanced Member

Profile Information

  • Gender
    Not Telling
  1. genista

    How to bring existing value into dropdown

    Spot on thank you so much!
  2. I have a dropdown where the options are pulled from a database into an array for display. This works fine, what I am trying to understand is how to incorporate showing the selection a user has made previously that was written to a table. I understand how to do this without an array (by checking if it is set and then pushing selected to display it) but this I am struggling with. I have a value pulled from a select statement, if that is set I want to mark the right value in the dropdown as selected. This below is not displaying that, it just shows the first option in the drop down. What am I missing? $statid is set from a select statement earlier in the script, printing it displays the value no problem result_stat_query = $DB_con->prepare('SELECT statid, stat_name FROM stats ORDER BY statid'); $result_stat_query->setFetchMode(PDO::FETCH_ASSOC); $result_stat_query->execute(); $row_stat = $result_stat_query->fetchAll(); echo "<select name='stat_id' onchange='filterContent(this);'>"; foreach ($row_stat as $r) { if (isset($statid)){ echo "<p>statid=$statid</p>"; echo '<option value='.$statid.'>'.$r['stat_name'].'</option>'; } else{ // first run echo '<option value="'.$r['statid'].'">'.$r['stat_name'].'</option>'; } } echo "</select>"; Thanks, G
  3. genista

    Results from Infinite Scroll

    Thanks, so if that is not the issue, what is causing the results to start again once the user gets to the end?
  4. Hi, I have an infinite scroll scipt that is pulling data and displaying it just fine. However, I am finding that when you scroll down the data pull starts again at the beginning. Right now I have 8 rows for testing in the database to make it easy. My control to get the next data set does not seem to be working otherwise it would go to the next set of results? PHP Code: //item per page $limit = 5; $page =(int)(!isset($_GET['p']))?1: $_GET['p']; // sql query $sqlContent="SELECT make, model, year, carid FROM cars"; //Query start point $start =($page * $limit)- $limit; $resContent=$DB_con->query($sqlContent); $rows_returned= $resContent->rowCount();//->fetchColumn(); // query for page navigation if( $rows_returned > ($page * $limit)){ $next =++$page; } $sqlContent = $sqlContent ." LIMIT $start, $limit"; $finalContent = $DB_con->query($sqlContent); if($finalContent === false) { trigger_error('Error: ' . $DB_con->error, E_USER_ERROR); } else { $rows_returned= $finalContent->rowCount();//->fetchColumn(); } ?> then display the results: PHP Code: PHP Code: <?php while($rowContent = $finalContent->fetch()) { $year = $rowContent['year']; $make = $rowContent['make']; $model = $rowContent['model']; ?> <div class="row"> <div class="ride"><?php echo "$year $make $model"; ?></div> </div> <?php } ?> </div> </div> <!--page navigation--> <?php if(isset($next)):?> <div class="nav"> <a href='index.php?p=<?php echo $next?>'>Next</a> </div> <?php endif ?> </div> When I print some of the variables, this is what I get: start=0 rows_returned = 5 next=2 page=2 Page 2 starts from the beginning, shouldn't that be 1 and then increment? Thanks, G
  5. genista

    Problem with invalid column on select

    Thanks, both responses have helped and solved the issue. G
  6. Hi, I am using GET to receive a variable from a url and then selecting from the DB where I find a match on that value. The problem, which I have never seen before the error tells me that the value is being used to find the column name: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'car' Here is the code, the get value is car - why is it doing this?! $type = $_GET['type']; $userid = $_SESSION['user_session']; //item per page$limit = 5; $page = filter_input(INPUT_GET, 'p', FILTER_VALIDATE_INT, array( 'options' => array('min_range' => 1, 'default' => 1))); $sqlContent="SELECT make, model, year, rideid FROM ride1 WHERE type = $type"; Thanks, G
  7. genista

    Updating Database problem

    Doh! Spot on, thanks for pointing that out
  8. genista

    Updating Database problem

    Hi, I am working my way through an image upload process and writing the file name to the database, which is where I am getting stuck. I am getting the error: PHP Catchable fatal error: Object of class PDO could not be converted to string on this piece of code (taken from the larger piece below): $stmt->$DB_con->prepare($query); Here is the full code from the script: userid = $_SESSION['user_session']; $stmt = $DB_con->prepare("SELECT rideid, userid, make, model, image1 FROM ride1 WHERE userid= :userid"); $stmt->execute(array(":userid"=>$userid)); $userRow=$stmt->fetch(PDO::FETCH_ASSOC); $image1 = $userRow['image1']; $rideid = $userRow['rideid']; if( ( $image1 == '' ) ) { $ds = DIRECTORY_SEPARATOR; //1 $storeFolder = '../ride_images'; //2 if (!empty($_FILES)) { $tempFile = $_FILES['file']['tmp_name']; //3 $targetPath = dirname( __FILE__ ) . $ds. $storeFolder . $ds; //4 $image1 = $targetPath.$userid.$rideid. $_FILES['file']['name']; //5 move_uploaded_file($tempFile,$image1); //6 $query ="UPDATE ride1 SET image1= :image1 WHERE rideid= :rideid"; $stmt->$DB_con->prepare($query); /* However, you pull your data in, I just used $image1 & $rideid for the example */ $stmt->execute([ ':image1' => $image1, ':rideid' => $rideid ]); Any help you can give would be much appreciated. Thanks, G
  9. genista

    Problem with DIV in Loop

    Thanks, and you are right. Looking at your fiddle it seems I need to increment a value for each panel button within each box in php to have this work individually rather than for all boxes? G
  10. genista

    Problem with DIV in Loop

    All, I am taking the output for every title in my Database and displaying it in a box. Within that box I am providing the opportunity to open another box with further content inside. The problem with the code below is that when you click on the expand button it expands in all the boxes, not just the one you are clicking in. I don't understand why this is happening when everything else is ok - any fixes and explanations are greatly appreciated: // GOING THROUGH THE DATA if($result->num_rows > 0) { //echo "<hr />"; while($fetch=mysqli_fetch_array($result)) { $title=$fetch['title']; $feed_rss=$fetch['url']; $content_id=$fetch['content_id']; $source_image=$fetch['source_image']; $item_id = $fetch['item_id']; $item_title = $fetch['item_title']; $item_date = $fetch['fetch_date']; $item_description = $fetch['item_description']; $item_url = $fetch['item_url']; ///////////////////////////////////////////////////////////////////////////////// // ?> <div class="box col5"> <?php $query_string = "cid={$content_id}&t={$item_id}&item_title={$item_title}"; $url_query_string = "http://www.disciply.com/article/index.php?" . $query_string; /*Start of dynamic content open*/ echo "<p>$title</p>"; echo "<img src=$source_image />"; echo "<p>item_url = $item_url</p>"; ?> <div class="panel_button" style="display: visible;"><img src="../images/expand.png" alt="expand"/> <a href="#"><?php echo $item_title; ?></a></div> <div class="panel_button" id="hide_button" style="display: none;"><img src="../images/collapse.png" alt="collapse" /> <a href="#">Hide</a> <object type="text/html" data='<?php echo $item_url;?>' width="100%" height="800px" style="overflow:auto;border:5px ridge blue"> </object> </div> </div>
×

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.