PHP - Echoes Only 1 Row
i have this function
Code: [Select] function friends($info) { mysql_connect("localhost", "kiphi", "bncorjnn") or die(mysql_error()); mysql_select_db("kiphi_comments") or die(mysql_error()); $count = "SELECT COUNT(*) as num FROM friend_requests where username='$info'"; $count2 = mysql_fetch_array(mysql_query($count)); $ol2 = "SELECT * FROM friends INNER JOIN active_users ON friends.friendname=active_users.username where friends.username='$info'"; $fetchol= mysql_query($ol2) or die("Could not get threads"); while ($online = mysql_fetch_array($fetchol)){ $friend['online'] = $online[friendname];} return $friend;} and then i use this to call the function above Code: [Select] $friend=friends($session->username); echo $friend['online']; what it does is checks the active users and then compares it to your friend list and then echo those friends that are online, problem is it only shows 1. i tried the Count(*) and it shows 3. i think i need to use, 'while' but i dont know where to put it Similar TutorialsSome of the dates (timestamp) in my database have a value of 0000-00-00 00:00:00 when I echo out the date - I see 1969-12-31 19:00 Code: [Select] echo 'Date Added - ' . date("Y-m-d G:i ", strtotime($row['time_added'])).'<br/>'; anyone know why ...is it because 0000-00-00 is not a valid date? any way to make it display the words "n/a" instead of the 1969-12-31 Folks,
Look at this weird thing. I load the page and get echoed as expected: Did Not REQUEST_METHOD! Then, I click the SUBMIT button and to my astonishment I get echoed: Did Not POST->Submit! Got 2 buttons. Same result whenever clicking any. Why is that ? Check it out:
<?php //include('error_reporting.php'); ini_set('error_reporting',E_ALL);//Same as: error_reporting(E_ALL); ini_set('display_errors','1'); ini_set('display_startup_errors','1'); ?> <form name = "submit" method = "POST" action=""> <label for="domain">Domain:</label> <input type="text" name="domain" id="domain" placeholder="Input Domain"> <br> <label for="domain_email">Domain Email:</label> <input type="email" name="domain_email" id="domain_email" placeholder="Input Domain Email"> <br> <label for="url">Url:</label> <input type="url" name="url" id="url" placeholder="Input Url"> <br> <label for="link_anchor_text">Link Anchor Text:</label> <input type="text" name="link_anchor_text" id="link_anchor_text" placeholder="Input Link Anchor Text"> <br> <textarea rows="10" cols="20">Page Description</textarea> <br> <label for="keywords">Keywords:</label> <input type="text" name="keywords" id="keywords" placeholder="Input Keywords related to Page"> <br> <input type="checkbox" name="alert_visitor_type" id="alert_visitor_type" value="Give Alert: Visitor Type"> </label for="alert_visitor_type">Give Alert: Visitor Type</lablel> <input type="checkbox" name="alert_visitor_potential" id="alert_visitor_potential" value="Give Alert: Potential Visitor"> </label for="alert_visitor_potential">Give Alert: Potential Visitor</lablel> <br> <input type="radio" name="tos_agree" id="tos_agree_yes" value="yes"> <label for="tos_agree_yes">Yes:</label> <input type="radio" name="tos_agree" id="tos_agree_no" value="no"> <label for="tos_agree_no">No:</label> <br> <label for="tos_agreement">Agree to TOS or not ?</label> <select name="tos_agreement" id="tos_agreement"> <option value="yes">Yes</option> <option value="no">No</option> </select> <br> <button type="submit" value="submit">Submit</button><br> <button type="submit">Submit</button> <br> <input type="reset"> <br> </form> <?php if($_SERVER['REQUEST_METHOD'] === 'POST') { if(isset($_POST['submit'])) { mysqli_report(MYSQLI_REPORT_ALL|MYSQLI_REPORT_STRICT); mysqli_connect("localhost","root","","test"); $conn->set_charset("utf8mb4"); $query = "INSERT into links (domain,domain_email,url,link_anchor_text,page_description,keywords,alert_visitor_type,alert_visitor_potential) VALUES (?,?,?,?,?,?,?,?)"; $stmt = mysqli_stmt_init($conn); if(mysqli_stmt_prepare($stmt,$query)) { mysqli_stmt_bind_param($stmt,'ssssssss',$_POST['domain'],$_POST['domain_email'],$_POST['url'],$_POST['link_anchor_text'],$_POST['page_description'],$_POST['keywords'],$_POST['alert_visitor_type'],$_POST['alert_visitor_potential']); if(mysqli_stmt_execute($stmt) === FALSE) { die("Error\" . mysqli_stmt_error()"); } mysqli_stmt_close($stmt); mysqli_close($conn); } else { die("Did not INSERT!"); } } else { die("Did Not POST->Submit!"); } } else { die("Did Not REQUEST_METHOD!"); } ?>
|