-
Posts
837 -
Joined
-
Last visited
Everything posted by samshel
-
Check this : http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-format something like the following should give you what you want: SELECT * FROM tbl_name WHERE date_format(dt, '%m') = 3 Change the table name and field names accordingly.
-
Check this. http://dev.mysql.com/doc/refman/5.0/en/ansi-diff-select-into-table.html
-
for($i=0;$i<count($files);$i++){ echo $files[$i].'-'; }
-
Only display if date is after current date (Date: YYYY - MM - DD)
samshel replied to Clarkie's topic in PHP Coding Help
Check strtotime function. It converts a date into Unix timestamp. You can convert both current date and date to compare in unix timestamp [which is in seconds] and do a <= comparison. -
Not sure...Try outside for loop $DOMDocument->getElementsByTagName( 'mar' )->getAttribute('name')
-
Is this is all the code in your file? Also try removing line 2 completely and typing by hand if you had copy pasted it. If you are including any other file before this code, there might be an open double quotes.
-
Please help! I go live tomorrow! (MySQL/PHP unknown error!
samshel replied to jessejarvis's topic in PHP Coding Help
2 cents. You can simplify this by dividing this into 2 steps. 1) fetch all rid for id = 13 2) build simple insert without subqueryies something like: $strSelect = "SELECT * FROM oto_members WHERE id='".$_REQUEST["rid"]."'"; $objResult = mysql_query($strSelect); $arrResult = mysql_fetch_array($objResult); $qry="INSERT INTO ".$prefix."members(firstname,lastname,email,address,city,state,postcode,country,telephone,username,password,refid1,refid2,refid3,refid4,refid5,refid6,refid7,refid8,refid9,refid10,geo,paypal_email,joindate,mtype,groupid,cb_id,status,signupip) VALUES('".$_REQUEST["firstname"]."','".$_REQUEST["lastname"]."','".$_REQUEST["email"]."','".$_REQUEST["address"]."','".$_REQUEST["city"]."','".$_REQUEST["state"]."','".$_REQUEST["postcode"]."','".$_REQUEST["country"]."','".$_REQUEST["telephone"]."','".$_REQUEST["username"]."','".md5($_REQUEST["password"])."', '".$_REQUEST["rid"]."', '".$arrResult['refid1']."', '".$arrResult['refid2']."', '".$arrResult['refid3']."', '".$arrResult['refid4']."', '".$arrResult['refid5']."', '".$arrResult['refid6']."', '".$arrResult['refid7']."', '".$arrResult['refid8']."', '".$arrResult['refid9']."', '".$_REQUEST["geo"]."','".$_REQUEST["paypal_email"]."',NOW(),".$_REQUEST["mtid"].",$eogroup,'".$_REQUEST["cb_id"]."','$memberstatus','$signupip')"; PS : Code not tested. -
Thanks for the replies. I worked around using array_multisort. It worked.
-
Hi, Following is the problem i am facing. Any help would be greatly appreciated. I have an associative array: array(5) { [66]=> int(1) [244]=> int(1) [181]=> int(1) [256]=> int(1) [233]=> int(1) } If i run arsort on this array, it returns me the following result: array(5) { [233]=> int(1) [256]=> int(1) [181]=> int(1) [244]=> int(1) [66]=> int(1) } Since values of all elements are same (1), it should return the array as it is. However looks like arsort reverses the order of elements if the values are same. Above example is just one use case. In cases where the values are different, it returns correct results.
-
Gathering Print Outs Of URL Links In <DIV>?
samshel replied to happyhippy's topic in PHP Coding Help
Try this : foreach($html->find('div[id=web]') as $div) { foreach($div->find('a') as $element) { echo $element->href . '<br>'; } } //OR $div = $html->find('div[id=web]'); foreach($div->find('a') as $element) { echo $element->href . '<br>'; } -
try this. not tested but might work. <{assign var="title" value=$people->getShow()|cat:$people->getName()|escape}>
-
Not sure what you are trying to do here $laggtill = "insert into narvaro_3manna (fornamn, efternamn, narvaro_id, datum) SELECT fornamn, efternamn, narvaro_id, (datum) VALUES ('$datum') WHERE datum = '2011-09-01'"; Do you want to insert 1 record or all records for that date from some table into narvaro_3manna ?
-
<?php if($_GET['place']==addnetwork){ //display current networks echo "<table border=1>"; echo "<tr><td>Network Name</td><td>URL</td></tr>"; $result = mysql_query("select name,url from s_links"); while ($query1 = mysql_fetch_assoc($result)) { $networkname = $query1['name']; $networkurl = $query1['url']; echo "<tr><td>$networkname</td><td>$networkurl</td></tr>"; } echo "</table>"; } ?>
-
Whats the exact error you are getting ?
-
mysql_query("UPDATE user_info SET balance = balance + $balance WHERE id = $id");
-
Hi All, Need some help with a query. Following is the situation: table : user user_id user_name 1 User_1 2 User_2 3 User_3 user_categories user_id cat_id 1 1 1 2 1 3 2 1 2 2 3 1 I need to find users who belong to all three categories [1,2,3]. In this case only user_id 1 should be returned. I cannot use "IN" as it checks for any 1 value from the set. I need records which have all cats. I cannot use "AND" as one record contains only 1 category. PS: Handling in code will be easy however I need to do it in single query Any help is really appreciated. Good Day !!
-
try this if ($test1 != "Select One") { $test1= "test1=".$_Post['']; // i know syntax is wrong but this isnt my problem } else { $test="1"; // This is where i am having problems. If the user doesnt select a option on my dropdown it pretty much removes all the data from query results because they have input. } $dlquery = "SELECT * FROM Whatever WHERE $test AND test2='$test2'"; ?> [code]
-
You can increase the 30 second counter by using set_time_limit [http://php.net/manual/en/function.set-time-limit.php] though, in case it works for you.
-
you cannot put php tags inside echo statement. If you are using echo, that means php tags are already opened. // echo out the contents of each row into a table echo "<tr>"; echo '<td nowrap>'; if ($DataDue > CURDATE()) {echo "OK";} elseif ($DateDue < CURDATE()) {echo "LATE";} else {echo "Warning";} echo mysql_result($result, $i, 'DateDue') . '</td>'; echo '<td nowrap>' . mysql_result($result, $i, 'Description') . '</td>'; echo '<td nowrap>' . mysql_result($result, $i, 'CompanyName') . '</td>'; echo "</tr>";
-
If you sleep in between your script it doesnt reset the 30 seconds counter, if thats what you are trying to do.
-
not sure if u understand u correct. u can try following code and confirm i understand u correct removed the group_concat and pulled out the content out of the loop assuming you will have only one post with that id. <?php $query = $link->query("SELECT p.*, u.u_username, u.u_posts, u.u_avatar, u.u_signature, u.u_avatar_cropped, a.a_name attachments FROM ".TBL_PREFIX."posts as p JOIN ".TBL_PREFIX."users as u ON (u.u_username = p.p_poster) LEFT JOIN ".TBL_PREFIX."post_attachments as a ON (p.p_pid = a.a_pid) WHERE p.p_tid = '$tid' GROUP BY p.p_pid ORDER BY p.p_time_posted ASC")or die(print_link_error()); $row = $query->fetchAll(); $title = array(); //FEtching records for 1 post only so first record should give u the content. $p_content = str_replace('<br>', '', $row[0]['p_content']); foreach($row as $key => $value) { $title[] = $row[$key]['attachments']; $bb[$key] = "#\[attachment=(.*?)\]#si"; $html[$key] = '<div>'.$title[$key].'</div>'; $p_content = preg_replace($bb[$key], $html[$key], $p_content); } echo $p_content; ?> [/code]
-
Need to understand what you are trying to do and how many records are there in all three tables.
-
How about using ON CLAUSE with both table and field names something like SELECT p.*, u.u_username, u.u_posts, u.u_avatar, u.u_signature, u.u_avatar_cropped, group_concat(a.a_name, a.a_size, a.a_date_posted separator '<br />') attachments FROM asf_posts as p JOIN asf_users as u ON (u.u_username = p.p_poster) LEFT JOIN asf_post_attachments as a ON (p.p_pid = a.p_pid) /* replace proper field names from respective tables here */ WHERE p.p_tid = '158' GROUP BY p.p_pid ORDER BY p.p_time_posted ASC
-
Try this: SELECT p.*, u.u_username, u.u_posts, u.u_avatar, u.u_signature, u.u_avatar_cropped, group_concat(a.a_name, a.a_size, a.a_date_posted separator '<br />') attachments FROM asf_posts as p JOIN asf_users as u ON (u.u_username = p.p_poster) LEFT JOIN asf_post_attachments as a USING (p_pid) WHERE p.p_tid = '158' GROUP BY p.p_pid ORDER BY p.p_time_posted ASC or you can try using "ON" instead of "USING" and specify field names from both tables as you have done for JOIN asf_users
-
move input box at the end of a previous echo line?
samshel replied to sdowney1's topic in PHP Coding Help
Agree with doddsey..or u can try if this works for you assuming $page_pagination is a string with no HTML components. echo '<FORM NAME="Library Search" ACTION="z3950get.php" METHOD="POST">'; echo '     Or go to page number '; echo '<input type="text"SIZE="5" name="pageinput2" value="'. $page_num.'">'; echo '<input type="hidden" name="recordcount" value="'.$recordcount.'"/>'; echo $page_pagination; echo '<button type="submit" name="pageinput1" value="search">Search</button>'; echo '</FORM>'; echo '<BR><BR>'; echo 'Showing Page Number -> '.$page_num. ' | Total number of results -> '.$numrows . ' | Total number of pages -> '.$numofpages.'<BR><BR>';