Jump to content

Search the Community

Showing results for tags 'rows'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

Found 10 results

  1. Hi all I want to display the same drop down list (selection) in every row of my table but I can't seem to work out how to do it, the drop down always seems to come at the end of the table and not on each row. The drop down list is a SQL query (a stored procedure) which is called. I managed to get the dropdown to appear in the correct place when it's just one row in a table. <?php $statement = db()->prepare("EXEC fe_uspAdminUserShowRegisteredAgencies"); $statement->execute(); $agencies= $statement->fetchAll(PDO::FETCH_ASSOC); ?> <p> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <table> <thead> <tr bgcolor="#FFF8DC"></b> <th><center><i>inviter</th> <th><center><i>inviter email</th> <th><center><i>inviter contact</th> <th><center><i>inviter region</th> <th><center><i>inviter skill</th> <th>refer to</th> <th></th> </i> </center> </tr> </thead> <p> </p> <?php if($inviterdetails) { foreach ($inviterdetails as $inviterdetail) { echo "<tr bgcolor=#FFF8DC>"; echo "<td><center>" . $inviterdetail['fullname'] . "</td>"; echo "<td><center>" . $inviterdetail['inviteremail'] . "</td>"; echo "<td><center>" . $inviterdetail['invitercontact'] . "</td>"; echo "<td><center>" . $inviterdetail['inviterregion'] . "</td>"; echo "<td><center>" . $inviterdetail['inviterskill'] . "</td>"; echo "<form action=LogReferal.php?email=referto>"; // echo "<td><left><input type=email id=referto name=referto></td>"; echo "<input type=hidden name=referred value=$inviterdetail[inviteremail]>"; echo "<td><left><input type=submit value=refer></td>"; } } ?> <td><select name="referto" id ="referto"> <?php foreach($agencies as $agencylist) { echo "<option><name=referto type=email>" . $agencylist['email'] . "</option>"; } Produces the desired result However when I try to repeat the process in a separate table which has multiple rows, I get the selection drop down all over the place in this case at the end of the row and not applicable to any particular row. I have managed to get it everywhere except on the row it should be and it doesn't repeat and be relevant to the row. <?php //Connection details section.. $email = current_user(); $statement = db()->prepare("EXEC fe_uspConnectionDetails ?;"); $statement->bindParam(1, $email, PDO::PARAM_STR); $statement->execute(); $details = $statement->fetchAll(PDO::FETCH_ASSOC); ?> <p> <p> <table> <thead> <tr> <th><i>name</th> <th><i>email</th> <th><i>skill</th> <th><i>mobile</th> <th><i>region</th> <th><i>days</th> <th><i><center>refer to</center></th> </tr> </thead> <hr color="#c7c34c" size="4" width="50%"> <p><i>my connections (below)</i></p> <?php if($details) { foreach ($details as $detail) { echo "<td><left>" . $detail['fullname'] . "</td>"; echo "<td><left>" . $detail['connectionemail'] . "</td>"; echo "<td><left>" . $detail['skill'] . "</td>"; echo "<td><left>" . $detail['phonenumber'] . "</td>"; echo "<td><left>" . $detail['region'] . "</td>"; echo "<td><left>" . $detail['daysremaining'] . "</td>"; echo "<form action=LogReferal.php?email=referto>"; // echo "<td><left><input type=email id=referto name=referto></td>"; echo "<input type=hidden name=referred value=$detail[connectionemail]>"; echo "<td><left><input type=submit value=refer></td>"; // echo "<form action=LogReferal.php?email=referto>"; // // echo "<td><left><input type=email id=referto name=referto></td>"; // echo "<input type=hidden name=referred value=$inviterdetail[inviteremail]>"; // echo "<td><left><input type=submit value=refer></td></tr></form>"; } } ?> <td><select name="referto" id ="referto"> <?php foreach($agencies as $agencylist) { echo "<option><name=referto type=email>" . $agencylist['email'] . "</option>"; } ?> </td> I kind of realise the repeating code (for each) has to be somewhere in the main table and not outside the table but I have just got stuck... Any help greatly received Cheers Greg
  2. Here's what I am trying to do. Retrieve "title" and "slug title" from all the rows in a table. Update them with new "title", "slug title" and "brand name". Here's my query. It updates the table with the brand names for each row. But for some reason, it removes the title and slug title from all the rows in the table. Is there a reason why it's doing that? function getIt($var) { $pos = strpos($var, ' - '); echo(substr($var, $pos+3)."\n"); } if(isset($_POST['submit'])) { $get_record = $db->prepare("SELECT * FROM items"); $get_record->execute(); $result_record = $get_record->fetchAll(PDO::FETCH_ASSOC); if(count($result_record) > 0){ foreach($result_record as $row) { $get_item_id = intval($row['item_id']); $get_item_title = trim($row['item_title']); $get_item_title_slug = trim($row['item_title_slug']); $new_title = getIt($get_item_title); $new_title_slug = Output::createSlug($new_title); $brand_name = substr($get_item_title, 0, strpos($get_item_title, ' - ')); $update_record = $db->prepare("UPDATE items SET brand_name = :brand_name, item_title = :item_title, item_title_slug = :item_title_slug WHERE item_id = :item_id"); $update_record->bindParam(':item_id', $get_item_id); $update_record->bindParam(':brand_name', $brand_name); $update_record->bindParam(':item_title', $new_title); $update_record->bindParam(':item_title_slug', $new_title_slug); if(!$update_record->execute()) { $errors[] = 'There was a problem updating the item.'; } } } else { $errors[] = 'No item found.'; } }
  3. Hi all, thank you for taking time to browse my thread. I have had some code written for me a while back which fetches either 1 or 2 rows from a database depending on if there are one or two rows based on the date. What it does is simply keep track of lotto results for each of the 2 daily draws along with the booster ball. Now, here's what I'm trying to do. Each row should really have it's own header such as Lunchtime or Teatime based on the draw number fetched from the database. I'm struggling a little. I understand how the code works and that I should have some kind of if/else (I think) in there, but I can't understand where or how to place it. Here is the current code <?php $color_mapping=array('0'=>'BLUE','1'=>'GREEN','2'=>'RED','3'=>'ORANGE','4'=>'YELLOW','5'=>'BROWN','6'=>'VIOLET', '7'=>'BLUE'); for($i = 0; $i < count($rows); $i++) { $res = explode(",", $rows[$i]['result']); $rRows = array(); //echo "<tr><td><p style='float:left;'>".$rows[$i]["draw_nr"].".</p></td>"; for($j = 0; $j < count($res); $j++) echo "<img class='ball' src='http://www.number49s.co.uk/images/fortyninesballs/".$res[$j].".gif'>"; echo "<td><img class='ball booster img-responsive' src='http://www.number49s.co.uk/images/fortyninesballs/".$rows[$i]["booster_ball"].".gif'></td><p style='clear:both;'></p>"; } From what I understand it fetches the results, turns them into an array and pulls each ball separately, from the rows and then appends the booster ball result for the current row. I'm thinking that it should have an if statement around $rRows array which reads if there is only a single row (based on draw number and date) and if it is outputs the code for the single row, then the else statement outputs the code for both. With a different header for each row I know I look like an idiot to you guys (and gals) who know this stuff inside out, but I am trying to learn although sadly this is WAY out of my ability at the moment. Any help as to where to place the if statement and how to get the results based on row number would be very gratefully accepted, but please don't be rude, I know I'm asking a lot, and I also know I know very little compared to the rest of you, but it doesn't give you warrant to be nasty. Thank you in advance to anybody who may be able to help me get this working, it's been driving me nuts for over 3 hours now
  4. so what im doing is ; im trying to get the rows from database with my following php code , and display them like ; <?php echo $col;?> , but its not working and giving me a blank result , a help would be greate thanks : <?php $stmt = $mysqli->prepare("SELECT * FROM `movies` ORDER BY `date` DESC LIMIT 0, 4"); $stmt->execute(); // Execute the prepared query. $stmt->store_result(); if($stmt->num_rows == 1) { $stmt->bind_result($id,$title,$poster,$date); // get variables from result. $stmt -> fetch(); } ?>
  5. Hello, i cant understand what the problem is .... when i add the css file you cant see what i echo out but only the tables and when i delete the css file everithing work fine... Here is the php file. maybe something is wrong here.. $sql = "SELECT * FROM producten"; $myData = mysql_query($sql,$con); echo '<table border="0" width="100%" cellpadding="0" cellspacing="0" id="product-table"> <tr> <th class="table-header-check"><a id="toggle-all" ></a> </th> <th class="table-header-repeat line-left minwidth-1"><a href="">Product</a> </th> <th class="table-header-repeat line-left minwidth-1"><a href="">Categorie</a></th> <th class="table-header-repeat line-left"><a href="">Beschrijving</a></th> <th class="table-header-repeat line-left"><a href="">Nr</a></th> <th class="table-header-repeat line-left"><a href="">Prijs</a></th> <th class="table-header-options line-left"><a href="">Options</a></th> </tr>'; while($record = mysql_fetch_array($myData)){ echo "<tr>"; echo '<td><input type="checkbox"/></td>'; echo "<td>" . " " . $record['Product'] ." </td>"; echo "<td>" . " " . $record['Item'] . " </td>"; echo "<td>" . " " . $record['Description'] . " </td>"; echo "<td>" . " " . $record['Extra'] . " </td>"; echo "<td>" . " " . $record['Valuta'] . " </td>"; echo "<td>" . " " . $record['Price'] . " </td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> Thanks for any help.
  6. I have a table displaying database data and there's a "Dead" button next to each row for users to click when the information in that row is dead. When the button is clicked the info in the row is crossed out. Now this works, but the change isnt permanent. When I refresh the page, the row is no longer crossed out. I think I have to set cookies.. ? but I am unsure on how to do this. Are there any tutorials or something I can watch on this. Just looking at http://php.net/manual/en/function.setcookie.php is not helping. I'm reading it and my brain is like.. what?!?! How do I apply that to what I want to do? Here's my code php <?php while($row = $data->fetch_assoc()) { ?> <tr> <td><?php echo $row['title']; ?> </td> <td><?php echo $row['requester']; ?></td> <td><?php echo $row['reward']; ?></td> <td><?php echo $row['qual']; ?></td> <td><?php echo $row['time']; ?></td> <td><?php echo $row['category']; ?></td> <td><a href="<?php $row['link']; ?>"><button class="btn btn-mini btn-primary" type="button">Do This Hit</button></a></td> <td><button class="btn btn-danger btn-mini dead" type="button">Dead</button></td> </tr> <?php } ?> and here's my javascript $('table').on('click','.dead',function(){ $(this).parent().siblings().css({textDecoration: 'line-through'}); }); I'm just totally stuck right now, so any help is appreciated. Also, if cookies arent the way to go, please feel free to suggest other ways. Thanks.
  7. Ok so basically I have created a simple blog for my website which does what I want it to do pretty much I'm having a problem with the date though If I echo the date out in to my page it just shows the main body of my content and not the actual date :/ the other problem is when I am echoing the blog into my page It is showing the same content two or three times instead of selecting the other content in the db I currently have two articles in my db but it will only show the article with the id of 1 instead of outputting id 1 and id 2 into there respective places on the page <?php $mysql = new mysqli('localhost', 'root', 'root', 'blog') or die('There was a problem connecting to the database'); $stmt = $mysql->prepare('SELECT id, title, date, author, category, LEFT(body, 600) AS excerpt, body from posts ') or die('Problem preparing the query'); $stmt->execute(); $stmt->bind_result($id, $title, $body, $author, $category, $excerpt, $date); while($row = $stmt->fetch()) : $lastspaceindex = strrpos($excerpt, ' '); ?> <?php endwhile; ?> then where I am echoing them out here my code is <div class="extra-wrap"> <span class="text3"><a href="blog.php?id=<?php echo $id; ?>" class="link1"><?php echo $title; ?> </a></span> <div class="inner4"> <p> Posted by <b><?php echo $author; ?></b> in <b><?php echo $category; ?></b> </p> </div> </div> <div class="clear"></div> <div class="page2-box2"> <figure class="page2-img1"><img src="images/page2-img2.jpg" alt=""></figure> <div class="extra-wrap"> <?php echo substr($excerpt, 0, $lastspaceindex) . "<a href='blog.php?id=$id'>...</a>"; ?><br> <span class="text3"><?php echo substr() . "<a href='blog.php?id=$id'>Read More</a>"; ?></span> </div>
  8. hej I'm making a website and have some problems with. Someone who can make a script where you have to press a button to delete all the rows in my table Thanks
  9. Hi, I'm trying to make a login form for my website, but I can't seem to get my head around this problem, basically it keeps returning this row error and I'm not too sure why? Really need some help on this, thanks. (Excuse my sloppy coding; just trying to get the basics to work atm) LOGIN.PHP <?php session_start(); include "dbConfig.php"; if ($_SERVER['REQUEST_METHOD'] == "POST") { $username = trim($_POST['username']); $password = trim ($_POST['password']); $query = "SELECT * FROM users WHERE username='$username' AND password='$password' LIMIT 1"; $result = mysql_query($query) or die(mysql_error()); if(!$result) { die("Wrong username or password."); } elseif(!mysql_num_rows($result)) { die("No user found by that username."); } else { Header("Location: memberstest.php"); exit(); } } ?> <form action="login.php" method="POST"> Username:<br> <input class="login_form" type="text" name="username" id="username" maxlength="20"> <br><br> Password:<br> <input class="login_form" type="password" name="password" id="password" maxlength="50"> <br><br> <button type="submit" name="submit" class="InputButton">Login</button> </form> REGISTER.PHP <?php session_start(); define('SALT_CHARACTERS', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'); function generate_salt() { $salt = ''; for($i = 0; $i < 21; $i++) { $salt .= substr(SALT_CHARACTERS, mt_rand(0, strlen(SALT_CHARACTERS) - 1), 1); } return $salt; } $errors = array(); if(isset($_POST['firstname']) && isset($_POST['lastname']) && isset($_POST['username']) && isset($_POST['email']) && isset($_POST['password'])){ require_once 'dbConfig.php'; $firstname = trim($_POST['firstname']); $lastname = trim($_POST['lastname']); $username = trim($_POST['username']); $email = trim($_POST['email']); $password = $_POST['password']; if($firstname == '') { $errors[] = 'Please enter your firstname.'; header("location: register.php?r=error"); } if($lastname == '') { $errors[] = 'Please enter your lastname.'; header("location: register.php?r=error"); } if($email == '') { $errors[] = 'Please enter an email address.'; header("location: register.php?r=error"); } if($username == '') { $errors[] = 'Please enter a username.'; header("location: register.php?r=error"); } if($password == '') { $errors[] = 'Please enter a password.'; header("location: register.php?r=error"); }elseif(strlen($password) < 6) { $errors[] = 'Your password must be at least 6 characters long.'; header("location: register.php?r=error"); } if(count($errors) === 0) { $passwordHash = crypt($password, '$2y$12$' . generate_salt()); $query = "INSERT INTO users(firstname, lastname, username, email, password) VALUES('$firstname', '$lastname', '$username', '$email', '$passwordHash')"; $result = mysql_query($query) or die(mysql_error()); if ($result) { header("location: register.php?r=success"); exit(); } else { die("Query failed"); } } } ?>
  10. I have a site for the Club I made, however I want to make it so that I can read the Session info, and then a certain Row for a user's page. I made their own personal webpages that get their information from the Session from MySQL. I want to try and see if all the information after a certain part will collect information from a different row. If that can't, is there a way it can be certain marks? I don't know how to explain it, but it is supposed to be that it keeps their username and other information that is requested on the site is active, but collects certain information from a row on the database. If you don't understand, go here: http://www.mcqtools.cu.cc/Club/member/ and login with test:test (username:password) then go to the 'Block' tab... I want their information to stay on the TOP of the page, like the user's name and all that, but the other information on the bottom of the block is from a certain row (userid=1) I don't know if I explained that right or not :/
  • 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.