PHP - Need A Code In Php - Show All Posts From A Irc Channel On Website
need a code in php - show all posts from a irc channel on website
if anyone knows how to do it, please let me know... i only need to display all the talking on mirc on my website. thank you Similar TutorialsThis topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=354184.0 I made this for my site and decided to share with the community. Depending on how you do the code and where, this can keep count of the views in different ways. Please read the somewhat directions have in the code, make a folder called counters, and be sure to include this below function file. I named the function file index.php and belongs in the counters folder you make. <?php /* name this file index.php and place it into a folder called counters the function will create a unique text file for each unique item, good for posts or pages and store all the files in the counters folder For the total website views,add this to your header file or top of your page <?php include('counters/index.php'); $website_view_url = "http://".$_SERVER['HTTP_HOST']; } $website_views = getViews("$website_view_url"); echo "<br />".$website_views."<br />"; ?> For the total pages or scripts views,add this to your header file or top of your page <?php include('counters/index.php'); $total_page_view_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']; } $total_page_views = getViews("$total_page_view_url"); echo "<br />".$total_page_views."<br />"; ?> For entire urls including queries,add this to your header file or top of your page <?php include('counters/index.php'); $page_queries_view_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']; if (!empty($_SERVER["QUERY_STRING"])) { $page_queries_view_url .= "?".$_SERVER['QUERY_STRING']; } $page_queries_views = getViews("$page_queries_view_url"); echo "<br />".$page_views."<br />"; ?> for usage in posts like by id: if do not want the pages counted and did not do the above code,include the below somewhere near the beginning of your page <?php include('counters/index.php');?> Then in the posts loop, you can associate your $row['id']; or some other unique value <?php $post_views = $row['id']; $post_views = getViews("$post_views"); echo "<br />Post Views ".$post_views."<br />"; ?> if would like to combine any the above or use them all, just be sure to just include include('counters/index.php'); only one time */ function getViews($views_count_value) { $views_count_value = md5("$views_count_value"); $views_count_file_name = "counters/$views_count_value.txt"; if (!file_exists($views_count_file_name)) { $views_count =0; $file_handle = fopen($views_count_file_name, 'w') or die("can't open file"); fwrite($file_handle, "$views_count"); fclose($file_handle); } $file_handle = fopen($views_count_file_name, "r"); $views_count = fread($file_handle, filesize("$views_count_file_name")); fclose($file_handle); if ($views_count <= 0){ $views_count =1; } else { ++$views_count; } $file_handle = fopen($views_count_file_name, "w+"); fwrite($file_handle, "$views_count"); fclose($file_handle); return("$views_count"); } ?> example : Code: [Select] <?php code; ?> how to change CSS (i guess this is the method) using php or javascript to organize text/code like <code></code> here ! i did a search and didnt found anything useful! I just had a question for you guys. I am building a forum script and I'm currently stumped on the "show unread posts since last visit" feature. Not sure as to how to code it. Should I be using a mysql database to keep track of them or use cookies some how? Thanks in advanced! Ok, as far as I know this code should update correctly, but for some reason it's not, and I can't seem to figure out why. Here is the page: http://kaboomlabs.com/testbed/edit.php?id=1 Mind you this is meant to be seen in IE only, so if it looks odd on your browser I haven't gotten to tweaking it yet.... thanks for the help. Code: [Select] <?php require_once('../connectvars.php'); echo '<div id="postwrap">' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>PDI NCMR - Edit</title> <link rel="stylesheet" type="text/css" href="../CSS/postie.css" /> </head> <body> <div id="logo"> <img src="../images/PDI_Logo_2.1.gif" alt="PDI Logo" /> </div> <?php if (isset($_POST['submit'])) { // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // Enter data into the database $ab = mysqli_real_escape_string($dbc, trim($_POST['ab'])); $date = mysqli_real_escape_string($dbc, trim(date('Y-m-d',strtotime ($_POST['date'])))); $part = mysqli_real_escape_string($dbc, trim($_POST['part'])); $rev = mysqli_real_escape_string($dbc, trim($_POST['rev'])); $partdesc = mysqli_real_escape_string($dbc, trim($_POST['partdesc'])); $ncmrqty = mysqli_real_escape_string($dbc, trim($_POST['ncmrqty'])); $comp = mysqli_real_escape_string($dbc, trim($_POST['comp'])); $ncmrid = mysqli_real_escape_string($dbc, trim($_POST['ncmrid'])); $rma = mysqli_real_escape_string($dbc, trim($_POST['rma'])); $jno = mysqli_real_escape_string($dbc, trim($_POST['jno'])); $fdt = mysqli_real_escape_string($dbc, trim($_POST['fdt'])); $cof = mysqli_real_escape_string($dbc, trim($_POST['cof'])); $fab1= mysqli_real_escape_string($dbc, trim($_POST['fab1'])); $fab2= mysqli_real_escape_string($dbc, trim($_POST['fab2'])); $fab3= mysqli_real_escape_string($dbc, trim($_POST['fab3'])); $non= mysqli_real_escape_string($dbc, trim($_POST['non'])); $dis= mysqli_real_escape_string($dbc, trim($_POST['dis'])); $comm= mysqli_real_escape_string($dbc, trim($_POST['comm'])); $caad= mysqli_real_escape_string($dbc, trim($_POST['caad'])); $po= mysqli_real_escape_string($dbc, trim($_POST['po'])); $pod = mysqli_real_escape_string($dbc, trim(date('Y-m-d',strtotime($_POST['pod'])))); $dri = mysqli_real_escape_string($dbc, trim(date('Y-m-d',strtotime($_POST['dri'])))); $query = "UPDATE ncmr SET ab = '$ab', date = '$date', part = '$part', rev = '$rev' , partdesc = '$partdesc' , ncmrqty = '$ncmrqty' , comp = '$comp' , ncmrid = '$ncmrid' , rma = '$rma' , jno = '$jno' , fdt = '$fdt' , cof = '$cof' , fab1 = '$fab1' , fab2 = '$fab2' , fab3 = fab3' , non = '$non' , dis = '$dis' , comm = '$comm' , caad = '$caad' , po = '$po' , pod = '$pod' , dri = '$dri' WHERE id = '" . $_GET['id'] . "'"; mysqli_query($dbc, $query); // Clear the form data $ab = ""; $date = ""; $part = ""; $rev = ""; $partdesc = ""; $ncmrqty = ""; $comp = ""; $ncmrid = ""; $rma = ""; $jno = ""; $fdt = ""; $cof = ""; $fab1= ""; $fab2= ""; $fab3= ""; $non= ""; $dis= ""; $comm= ""; $caad= ""; $po= ""; $pod = ""; $dri = ""; // Confirm success with the user echo '<p>If you wish to edit more NCMRs, please <a href="list.php">go to the admin page!</a></p>'; mysqli_close($dbc); } else { // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // Grab the profile data from the database if (!isset($_GET['id'])) { $query = "SELECT * FROM ncmr WHERE id = '$id'"; } else { $query = "SELECT * FROM ncmr WHERE id = '" . $_GET['id'] . "'"; } $data = mysqli_query($dbc, $query); if (mysqli_num_rows($data) == 1) { // The user row was found so display the user data $row = mysqli_fetch_array($data); echo'<div id="title"><h3 id="NCMR2">Non-Conforming Materials Report (NCMR: ' . $row['rma'] . ')</h3></div>'; echo "<form action='".$_SERVER['PHP_SELF']."' method='post'>"; echo '<fieldset>'; echo '<div id="box1">'; if (empty($row['ab'])) $row['ab'] = "Empty"; if (empty($row['date'])) $row['date'] = "Empty"; if (empty($row['part'])) $row['part'] = "Empty"; if (empty($row['rev'])) $row['rev'] = "Empty"; if (empty($row['partdesc'])) $row['partdesc'] = "Empty"; if (empty($row['ncmrqty'])) $row['ncmrqty'] = "Empty"; echo '<div id="ab"><span class="b">Added By: </span><input type="text" name="ab" value="' . $row['ab'] . '" /></div>'; echo '<div id="date"><span class="b">Date Filed: </span><input type="text" name="date" value="' . $row['date'] . '" /></div>'; echo '<div id="part"><span class="b">Part Number: </span><input type="text" name="part" value="' . $row['part'] . '" /></div>'; echo '<div id="rev"><span class="b">Part Revision: </span><input type="text" name="rev" value="' . $row['rev'] . '" /></div>'; echo '<div id="partdesc"><span class="b">Part Description: </span><textarea rows="4" cols="22">' . $row['partdesc'] . '</textarea></div>'; echo '<div id="ncmrqty"><span class="b">NCMR Qty: </span><input type="text" name="ncmrqty" value="' . $row['ncmrqty'] . '" /></div>'; echo '</div>'; //Company, Customer NCMR, Internal RMA, and Job Number echo '<div id="box2">'; if (empty($row['comp'])) $row['comp'] = "Empty"; if (empty($row['ncmrid'])) $row['ncmrid'] = "Empty"; if (empty($row['rma'])) $row['rma'] = "Empty"; if (empty($row['jno'])) $row['jno'] = "Empty"; echo '<div id="comp"><span class="b">Company: </span><input type="text" name="comp" value="' . $row['comp'] . '" /></div>'; echo '<div id="ncmrid"><span class="b">Customer NCMR ID: </span><input type="text" name="ncmrid" value="' . $row['ncmrid'] . '" /></div>'; echo '<div id="rma"><span class="b">Internal RMA #: </span><input type="text" name="rma" value="' . $row['rma'] . '" /></div>'; echo '<div id="jno"><span class="b">Job #: </span><input type="text" name="jno" value="' . $row['jno'] . '" /></div>'; echo '</div>'; //Type of Failure and Class of Failure echo '<div id="box3">'; echo '<h2>Failure</h2>'; echo '<div id="cof"><span class="b">Class of Failu </span><input type="text" name="cof" size="15" value="' . $row['cof'] . '" /></div>'; echo '<div id="fdt"><span class="b">Failure Due To: </span><input type="text" name="fdt" size="15" value="' . $row['fdt'] . '" /></div>'; echo '</div>'; //Fabricators echo '<div id="box4">'; echo '<h2>Fabricators</h2>'; if ($row['fab1']="--None--") { echo'<div id="fab1">'; $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $mysqli->select_db('user'); $result = $mysqli->query("SELECT * FROM user"); echo "<SELECT name='fab1'>\n"; while($row = $result->fetch_assoc()) { echo "<option value='{$row['user']}'>{$row['user']}</option>\n"; } echo "</select>\n"; echo '</div>'; } else { echo'<div id="fab1">'; $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $mysqli->select_db('user'); $result = $mysqli->query("SELECT * FROM user"); echo "<SELECT name='fab1'>\n"; while($row = $result->fetch_assoc()) { echo "<option value='{$row['user']}'>{$row['user']}</option>\n"; } echo "</select>\n"; echo '</div>'; } if ($row['fab2']="--None--") { echo'<div id="fab2">'; $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $mysqli->select_db('user'); $result = $mysqli->query("SELECT * FROM user"); echo "<SELECT name='fab2'>\n"; while($row = $result->fetch_assoc()) { echo "<option value='{$row['user']}'>{$row['user']}</option>\n"; } echo "</select>\n"; echo '</div>'; } else { echo '<div id="fab2"><span class="b"></span><input type="text" name="fab1" size="20" value="' . $row['fab1'] . '" /></div>'; echo '</div>'; } if ($row['fab3']="--None--") { echo'<div id="fab3">'; $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $mysqli->select_db('user'); $result = $mysqli->query("SELECT * FROM user"); echo "<SELECT name='fab3'>\n"; while($row = $result->fetch_assoc()) { echo "<option value='{$row['user']}'>{$row['user']}</option>\n"; } echo "</select>\n"; echo '</div>'; } else { echo '<div id="fab3"><span class="b"></span><input type="text" name="fab1" size="20" value="' . $row['fab1'] . '" /></div>'; echo '</div>'; } echo '</div>'; //Nonconformity, Disposition, Comments and Comments & Additional Details echo '<div id="box5">'; if (empty($row['non'])) $row['non'] = "Empty"; if (empty($row['dis'])) $row['dis'] = "Empty"; if (empty($row['comm'])) $row['comm'] = "Empty"; if (empty($row['caad'])) $row['caad'] = "Empty"; echo '<div id="non"><span class="b">Nonconformity: </span><textarea rows="4" cols="105">' . $row['non'] . '</textarea></div>'; echo '<div id="dis"><span class="b">Disposition: </span><textarea rows="4" cols="105">' . $row['dis'] . '</textarea></div>'; echo '<div id="comm"><span class="b">Comments: </span><textarea rows="4" cols="105">' . $row['comm'] . '</textarea></div>'; echo '<div id="caad"><span class="b">Comments and/or Additional Details: </span><textarea rows="4" cols="105">' . $row['caad'] . '</textarea></div>'; echo '<div id="podr">'; if (empty($row['po'])) $row['po'] ="Empty"; if (empty($row['pod'])) $row['pod'] ="Empty"; if (empty($row['dir'])) $row['dri'] ="Empty"; echo '<div id="po"><span class="b">PO: </span><input type="text" name="po" size="7" value="' . $row['po'] . '" /></div>'; echo '<div id="pod"><span class="b">PO Date: </span><input type="text" name="pod" size="7" value="' . $row['pod'] . '" /></div>'; echo '<div id="dri"><span class="b">Date Received: </span><input type="text" name="dri" size="7" value="' . $row['dri'] . '" /></div>'; echo '</div>'; echo '<div id="button2"><input type="submit" value="Submit Edits" name="submit" /></div>'; echo '</div>'; echo '</fieldset>'; echo '</form>'; } } echo '</div>'; ?> </body> </html> How would I show the PHP code on the website page? I'm not sure if this should be under PHP or HTML or what, but, like on the forums where you see the <?php echo 'sdfjksdf'; ?> etc. How do I make it so I can write PHP on the website? Hello all, Wondering if you can help me, I am wondering if it is possible to get PHP to show the last websites you viewed, just giving the names of the websites in a list. If so? is there any pointers someone can give me as to how to learn to achieve something like this..I'd really appreciate the help! Im running a website about health and foods. I would like that at the end of each article, it shows other related articles that I have on my website.
Im relatively new with php and mysql so I figure I have to put every page onto a database table.
I looked already everywhere but all I found is how to do with wordpress. But i'm not using anything like that.
I made the website myself with css and html and php.
Can somebody help me with a website where they explain how to do?
Also I would like that automatically it shows my latest articles in a sidebar. Without anytime adding myself manually.
Can anybody help me?
I want to show different content to different users from different states. So, if a visitor is visiting the website from California, I want to show California content. Likewise, if a user is visiting from any other State (say NY, Chicago, or anywhere), I want to show content relating to that State. Any suggestions? Thanks. I have an application that uses the PHP LDAP library to connect to the Windows Active Directory:
$ds = ldap_connect($ini['ad_server']) or die("Could not connect");
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); I am wondering if anyone knows if this upcoming patch "2020 LDAP channel binding and LDAP signing" coming from Microsoft will break any PHP applications that are using this ldap library. Thanks in advance,
M Hello, Here's the weird thing, some of the pages shows the results, and some pages just won't show results at all, and I'm not getting any errors here is the one that doesn't Code: [Select] <? function display_mptt($user) { global $db; // retrieve the left and right value of the $root node $sql2 = "SELECT * from mptt where id='25'"; $result2 = mysql_query($sql2 ,$db); if(!$row2 = mysql_fetch_array($result2)) echo mysql_error(); echo '<h1>Users List</h1>'; // start with an empty $right stack $right = array(); // now, retrieve all descendants of the $root node $sql = "SELECT * from mptt WHERE 'left' BETWEEN '".$row2['left']."' AND '".$row2['right']."' ORDER BY 'left' ASC"; $result = mysql_query($sql ,$db); // display each row while ($row = mysql_fetch_array($result)or die(mysql_error())) { // only check stack if there is one $count = mysql_num_rows($result); if (count($right)>0) { // check if we should remove a node from the stack while ($right[count($right)-1]<$row['right']) { array_pop($right); } } // display indented node title // add this node to the stack $var3 = '10'; echo "<table width='589' border='1'> <tr> <th>ID</th> <th>Name</th> </tr>"; echo "<tr><td><a href=\"user.php?id=".$row['id']."\">".$row['id']."</a></td>"; echo "<td>" . $row['title'] ." </td>"; echo "</tr>"; echo "</table>"; $right[] = $row['right']; } } display_mptt(1); ?> and here is the page that does Code: [Select] <? function display_mptt($user) { global $db; $id = $_GET['id']; // retrieve the left and right value of the $root node $sql2 = "SELECT * from mptt where id= ".$id.""; $result2 = mysql_query($sql2 ,$db); if(!$row2 = mysql_fetch_array($result2)) echo mysql_error(); echo '<h1>Your Tree</h1>'; // start with an empty $right stack $right = array(); // now, retrieve all descendants of the $root node $sql = "SELECT * from mptt WHERE `left` BETWEEN ".$row2['left']." AND ".$row2['right']." ORDER BY 'left' ASC"; $result = mysql_query($sql ,$db); // display each row while ($row = mysql_fetch_array($result)) { // only check stack if there is one if (count($right)>0) { // check if we should remove a node from the stack while ($right[count($right)-1]<$row['right']) { array_pop($right); } } // display indented node title echo str_repeat(' ',count($right)).$row['title']."<br>"; // add this node to the stack $right[] = $row['right']; } } display_mptt(1); ?> This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=314194.0 Hello People. Please can someone point me to where I can learn to program the following all one one page? Here is a screenshot of what I'm after. Idea being that you put hours and minutes into the top row. Then hours and minutes into the next row. Click the button and get the answer at the bottom. The answer to 1 hour 40 minutes added to 1 hour 40 minutes should obviously be 3 hours 20 minutes. Here's how I would approach it in another language, but am brand new to php hence the help required. Make the following variables. Hour1 Hour2 Minute1 Minute2 Total_Hours Total_Minutes Combined_Time I would then write something like Total_minutes = minute1 + Minute2 Total_hours = Hour1 + hour2 combined time = Total_hours * 60 + (Total_Minutes) // reset the total hours Total_hours = 0 Loop here.... while combined_time >60 Total_hours = Total_hours + 1 combined_time = combined time -60 re-do the loop Now in the boxes at the bottom put bottom hour box = total hours bottom minute box = combined_time (remaining minutes) here's the code I have so far. Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <table width="527" border="0" cellspacing="5" cellpadding="5" bgcolor="#c0c5c9"> <p>Time Calculator</p> <p>Put your hours and minutes in the top boxes. Click the add time button<br /> to get the answer </p> <table width="401" border="1" cellspacing="5" cellpadding="5"> <tr> <td width="109"><input type="int" name="hour01" size="10" maxlength="10" /> Hrs</td> <td width="251"><input type="int" name="min01" size="10" maxlength="10" /> Mins</td> </tr> <tr> <td><input type="int" name="hour02" size="10" maxlength="10" /> Hrs</td> <td><input type="int" name="min02" size="10" maxlength="10" /> Mins</td> </tr> <tr> <td><input type="submit" name="submit" value="Add Time" /></td> <td><input name="hour_answer" type="int" size="10" maxlength="10" /> Hrs <input type="int" name="minute_answer" size="10" maxlength="10" /> Mins</td> </tr> </table> <tr></tr> </body> </html> Hi all, The below example is a workable code, taken from tutor_profile.sql table Code: [Select] <?php $query = "SELECT tutor_id, religion_id FROM tutor_profile WHERE tutor_id = '" . $_GET['tutor_id'] . "'"; $data = mysqli_query($dbc, $query) or die(mysqli_error($dbc)); // The user row was found so display the user data if (mysqli_num_rows($data) == 1) { $row = mysqli_fetch_array($data); print_r($row); if ($row != NULL) { $religion_id = $row['religion_id']; $tutor_id = $row['tutor_id']; } else { echo '<p class="error">There was a problem accessing your profile.</p>'; } } <!--Religion--> <tr> <td class="label">Religion:</td> <td> <select id="religion_id" name="religion_id"> <option value="1" <?php if (!empty($religion_id) && $religion_id == '1') echo 'selected = "selected"'; ?>>Buddhism</option> <option value="2" <?php if (!empty($religion_id) && $religion_id == '2') echo 'selected = "selected"'; ?>>Christianity</option> <option value="3" <?php if (!empty($religion_id) && $religion_id == '3') echo 'selected = "selected"'; ?>>Hinduism</option> <option value="4" <?php if (!empty($religion_id) && $religion_id == '4') echo 'selected = "selected"'; ?>>Islam</option> <option value="5" <?php if (!empty($religion_id) && $religion_id == '5') echo 'selected = "selected"'; ?>>Taoism</option> <option value="6" <?php if (!empty($religion_id) && $religion_id == '6') echo 'selected = "selected"'; ?>>Others</option> </select> </td> </tr> ?> As you can see I have hard coded the names of the religion in html code example - <option value="3" <?php if (!empty($religion_id) && $religion_id == '3') echoselected = "selected"'; ?>>Hinduism</option> And if our record shows that the tutor has previously selected '3', it will reflect as 'hinduism' in his profile. View profile.jpg for example example - <option value="3" <?php if (!empty($religion_id) && $religion_id == '3') echo 'selected = "selected"'; ?>>Hinduism</option> In fact, these names can be found in another table called religion.sql, but I hard coded it anyway, without using loop (while function), since there are only 8 names Code: [Select] <!--Religion--> <tr> <td class="label">Religion:</td> <td> <select id="religion_id" name="religion_id"> <option value="1" <?php if (!empty($religion_id) && $religion_id == '1') echo 'selected = "selected"'; ?>>Buddhism</option> <option value="2" <?php if (!empty($religion_id) && $religion_id == '2') echo 'selected = "selected"'; ?>>Christianity</option> <option value="3" <?php if (!empty($religion_id) && $religion_id == '3') echo 'selected = "selected"'; ?>>Hinduism</option> <option value="4" <?php if (!empty($religion_id) && $religion_id == '4') echo 'selected = "selected"'; ?>>Islam</option> <option value="5" <?php if (!empty($religion_id) && $religion_id == '5') echo 'selected = "selected"'; ?>>Taoism</option> <option value="6" <?php if (!empty($religion_id) && $religion_id == '6') echo 'selected = "selected"'; ?>>Others</option> </select> </td> </tr> Currently I am facing an issue, I guess I will need to use looping, as there are 22 names in another table which I will need to call forth, tutor_educational_level.sql, and the number of names get more and more in other tables. My question is, how do I pull out the entire list of names into a drop down box and yet showing the selected name which the user has chosen, more elaboration can be seen in profile.jpg. In profile.jpg - as you can see the list of names are shown in the drop down box and the system is able to decipher the chosen name. Another Example 1) N level 2) O level 3) A level 4) University User selected '3', which is A level, and system would still show the list of educational_names in a drop down box,, but selecting A level as the one to appear. Example 1) N level 2) O level 3) A level (selected) 4) University It should have the same overall result as the religion which I have stated above, however this time round, it is using looping function (while) to retrieve the entire list of names, select and show the name which the user has chosen Below is my code, and I know it is wrong, but generally would like to relate my idea across. Code: [Select] <?php <!--Teaching Credentials--> <tr> <td class="label">Teaching Credentials:</td> <td> <?php echo '<select name="educational_level" id="educational_level">'; $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) or die(mysqli_error($dbc)); $query = "SELECT tp.educational_id, el.educational_name AS educational_name, el.educational_id AS list_educational_id " . "FROM tutor_profile AS tp " . "INNER JOIN * tutor_educational_level AS el USING (educational_id) " . "WHERE tp.tutor_id = '" . $_GET['tutor_id'] . "'"; $sql = mysqli_query($dbc, $query) or die(mysqli_error()); while($data = mysqli_fetch_array($sql)) { echo'<option value="'.$data['list_educational_id'].'">'.$data['educational_name'].'</option>'; if (!empty ($data['educational_id']) && ($data['educational_id']) == ($data['list_educational_id'])) { echo 'selected = "selected"'; } } echo '</select><br/>'; mysqli_close($dbc); ?> </td> </tr> ?> We are building a site for users to post articles on certain topics and we want to show their number of followers on various social media platforms. Apart from them having the means to add it manually, there must be a method of syncing with their account, that they punch in, so that it dynamically updates our database with their number of followers. How is it done? Hi Guys. Really Stuck here. I am making a website, its basicall an online shop of sorts. I am making a login page for our customers and an admin page for us lot to upload new products to sql etc. Whats its meant to do is accept the username and pw then allow me to access the adminpage. Although its just saying that user doesnt exist all the time. I dont know why becuase the details are correct. admin_login page is the code below. <?php session_start(); if(isset($_SESSION["manager"])){ header("location:index.php"); exit(); } ?> <?php if(isset($_POST["username"])&&isset($_POST["password"])){ $manager = preg_replace('#[A-Za-z0-9]#i','',$_POST["username"]); $password = preg_replace('#[^A-Za-z0-9]#i','',$_POST["password"]); include"../storescripts/connect_to_mysql.php"; $sql = mysql_query("SELECT id FROM admin WHERE username='$manager' AND password='$password' LIMIT 1"); $existCount = mysql_num_rows($sql); if($existCount == 1){ while($row = mysql_fetch_array($sql)){ $id = $row["id"]; } $_SESSION["id"] = $id; $_SESSION["manager"] = $manager; $_SESSION["password"] = $password; header("location: index.php"); exit(); }else{ echo 'That Information Is Incorrect. Try again <a href="index.php">Click Here</a>'; exit(); } } ?> and now the index.php which is what the admin see when they log in successfully. <?php session_start(); if(isset($_SESSION["manager"])){ header("location: admin_login.php"); exit(); } //Be Sure To Check That This Manager Session Value Is Infact In The DataBase $managerID = preg_replace('#[^0-9#i','',$_SESSION["id"]); $manager = preg_replace('#[^A-Za-z0-9]#i','',$_SESSION["manager"]); $password = preg_replace('#[^A-Za-z0-9]#i','',$_SESSION["password"]); include "../strorescripts/connect_to_mysql.php"; $sql = mysql_query("SELECT * FROM admin WHERE id='$managerID' AND username='$manager' AND password='$password' LIMIT 1"); $existCount = mysql_num_rows($sql); if($existCount == 0){ header("location:../index.php"); exit(); } ?> This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=355144.0 <?php query_posts('meta_key=post_views_count&posts_per_page=3&orderby=meta_value_num& order=DESC'); if (have_posts()) : while (have_posts()) : the_post(); ?> <ul class="rpul"> <li> <div class="class="post-thumb wp-post-image" style=' '> <?php if ( has_post_thumbnail() ) : ?> <?php the_post_thumbnail('thumbnail') ?> <?php endif ?> </div><div class='cat-post-text'> <h1> <a href="<?php the_permalink(); ?>"><?php the_title(); ?>
Hi All, Newbie here.
I run a website using xmb forums software as a base login script to connect to my database and created my own crude and simple pages for adding and displaying the data learning as I went. Over the years with recent upgrades of php versions its now virtually useless and unsecure code. I archive a lot of news articles but have had trouble pasting text that includes apostrophe's and special characters, but managed to fix that using addslashes() now. Can someone suggest a tutorial or a way to rebuild my site from scratch or something I can use as a template to connect to my pages ?. |