PHP - Logical Way Of Doing This
I made a bot, that scrapes content from a forum, i cant access the forum in work, so am trying to make something discreat to read it on my own site while at work. Anyway the links to threads are something like this.
I got help and i know how to extract the unique thread number using regex. However i have a problem. What i really need, now that i think about it, is a way of getting the thread number and the thread title (so i can make sense of what im reading.) The thread title is in the setWindowStatus function. I cant think of a way to do it. I dont even know if it would work in an array what id basically like is something that says 1) Thread title - Thread id 2) Thread title - Thread id etc that is stored in a way that i can easily manipulate. Code: [Select] <img src="http://s2.images.proboards.com/xx.gif" alt=" " border="0"/></font></td><td class="windowbg" bgcolor="FFFFFF" width="48%" style="cursor:pointer;" onClick="if(!pb_bubble)location.href='/index.cgi?board=general&action=display&thread=13483';" onMouseOver="mouseOverHighlightCell(this);setWindowStatus('Lurkers, show your face ');return true; Similar TutorialsOkay i'm trying to compare these sets of variables. code looks like this.. Code: [Select] if( $row->cash > $finalcash && $row->core1 > $finalcore1 && $row->core2 > $finalcore2 && $row->core3 > $finalcore3 && $row->core4 > $finalcore4 ) { return true; } else { return false; } First question is this the appropriate way of doing this? Or would a nested if statement work better? example: Code: [Select] if ($row->cash > $finalcash) { if ($row->core1 > $finalcore1) { if ($row->core2 > $finalcore2) { if ($row->core3 > $finalcore3) { if ($row->core4 > $finalcore4) { } else { return false; } } else { return false; } } else { return false; } } else { return false; } } else { return false; } I know it looks pretty messy, so i'm wondering if anybody is aware of an alternative to achieving this? Hi there,
This may not be the correct space to post this - but I'm very new to all this.
I've created a page that will run a php script to output a query. I would then like to send that same query via email - however from a design perspective I don't think the correct process is to click 'submit' to view the query and then 'submit' to send the result via email?
Can you please advise on some design solutions regarding this issue?
Thanks!
In php is there a way to shortcut logical operators... example: Code: [Select] if ($row['CustomerSaas'] == 'Yes' && ($row['CustomerSaasPaidStatus'] == 'Trial' || $row['CustomerSaasPaidStatus'] == 'Trial Ended')) { to Code: [Select] if ($row['CustomerSaas'] == 'Yes' && ($row['CustomerSaasPaidStatus'] == 'Trial' || 'Trial Ended')) { i have two tables assume question and answer question table consists of Question_Date, Question_id and Question_title answer table consists of Answer_Date, Question_id, Answer_id and Answer_title let say i have 1000 records and i wish to display only the last 100 records combining both question and answer. How can i do this with loop..any suggestion would be appreciate thanks im trying to make a salary system which would display a month salary according to login hours so i got two different tables storing data like
1. users table id, name, password, salary
2.attendance table id, user_id, Employee_Name, Remark, Login_Hours, Date
so what im looking to do is fetch all users id, name and salary from users table and then match it with attendance user_id,Employee_Name ,Login_Hours, table and then also count numbers of result for a particular year-month so that i could do the hourly wage calculation.
could someone help out i got no idea how to achieve it
apprieciate your help,
thanks
i tried something like this it does output something but still dunno how to match results of both tables and get result
$date = '2014-11'; $query1 = "SELECT COUNT(*) as num FROM attendance WHERE Date LIKE '%".$date."%' AND Employee_Name='moses'"; $total_pages = mysql_fetch_array(mysql_query($query1)); $total_res = $total_res[num]; // total rows counting of total office days of a month $result2=mysql_query("SELECT id, user_id, Employee_Name, Remark, SUM(Login_Hours), Date FROM attendance WHERE Employee_Name='moses'"); while($row = mysql_fetch_array($result2)){ echo $sal_to_month = 9000/$total_res; //9000 is salary should be fetched from users table echo '<br/>'; echo $sal_to_month/9*$row['SUM(Login_Hours)']; } Hi guys, i'm trying to increment a variable / session value whenever 'submit' comes in the POST. I can't seem to get around the logic of this. Code looks like this: Code: [Select] $var = 0 if($_POST('submit'){ $_SESSION['var2'] = $var++; } What I want it to do is increment the value of the session index everytime a user clicks 'submit'. But because i've reset $var to 0 everytime, it's always just going to stay at 1. I just can't think of a way to achieve this, does anyone have any clue on how I can? fixed. Hi there, First of all, I want to present the diagram that I'm working on. ----------- Diagram ----------- step2_a.php --| step2_b.php --|---> output.php step2_c.php --| (Process is included here) step2_d.php --| and here are the corresponding codes: step2_x: Code: [Select] . . . <form action="output.php" method="post" name="a"> req1: <input type="text" name="a_req_1"> req2: <input type="text" name="a_req_2"> . . . <input type="submit"> </form> ------ . . . <form action="output.php" method="post" name="b"> req1: <input type="text" name="b_req_1"> req2: <input type="text" name="b_req_2"> . . . <input type="submit"> </form> . . . . . . output.php: Code: [Select] <?php $form_name = $_POST['a']; if($form_name = "a") { //variables for a goes here //code goes here } elseif($form_name = "b") { //variables for b goes here //code goes here } elseif($form_name = "c") { //cariables for c goes here //code goes here } elseif($form_name = "d") { //variables for d goes here //code goes here } else { //code goes here } ?> Now, here's the problem. output.php always sees the primary condition as true. Even the data came from step2_b, the code does not recognize it. I tried to use "==" instead of "=" but the code sees the arguments as false so it executed the code on "else". How can I make the code distinguish the source of the data so that it would execute the right set of commands? Thanks in advance. I am creating a form that collects the details of users and then any errors cause for the error log to have errors noted and added to it. Part of my coding is this: Code: [Select] else if (is_numeric($name)||is_int($name) && is_numeric($surname)||is_int($surname)) { echo "It seems that you have entered numerical values for the First Name and Surname fields. This has been added to the error log.<br><br>"; error_log("<br><br><b><u>Presence Error</b></u><br>The user has entered numerical values for First Name and Surname fields!<br>First Name entered: " . $name . "<br>Surname entered: " . $surname . "<br>Age entered: " . $age . "<br>Number Of Complete Weeks Since Accident entered: " . $weeks . "<br>Time that form was submitted: " . $subtime . "<br><br>", 3, "C:/xampp/htdocs/errorlog.txt"); } else if (is_numeric($name)||is_int($name)) { echo "It seems that you have entered a numerical value for the First Name field. This has been added to the error log.<br><br>"; error_log("<br><br><b><u>Presence Error</b></u><br>The user has entered a numerical value for First Name fields!<br>First Name entered: " . $name . "<br>Surname entered: " . $surname . "<br>Age entered: " . $age . "<br>Number Of Complete Weeks Since Accident entered: " . $weeks . "<br>Time that form was submitted: " . $subtime . "<br><br>", 3, "C:/xampp/htdocs/errorlog.txt"); } else if (is_numeric($surname)||is_int($surname)) { echo "It seems that you have entered a numerical value for the Surname field. This has been added to the error log.<br><br>"; error_log("<br><br><b><u>Presence Error</b></u><br>The user has entered a numerical value for the Surname field!<br>First Name entered: " . $name . "<br>Surname entered: " . $surname . "<br>Age entered: " . $age . "<br>Number Of Complete Weeks Since Accident entered: " . $weeks . "<br>Time that form was submitted: " . $subtime . "<br><br>", 3, "C:/xampp/htdocs/errorlog.txt"); } so that if a user enters in numerical values when letters need to be entered, then this gets added to the error log. However, even if I enter in a suitable surname (i.e. Jones), the first path (where both the first name and surname are detected as being numerical) runs when I want the path where only the first name contains just digits to be run. Any idea how to fix this? Any help is appreciated! Thanks! |