sasa
Staff Alumni-
Posts
2,804 -
Joined
-
Last visited
-
Days Won
1
Everything posted by sasa
-
if (! preg_match('/^[a-zA-Z0-9]+$/i', $_POST['username'])) or if (preg_match('/[^a-z0-9]/i', $_POST['username']))
-
<?php $sometext = "myspace.com/bluemonkey00"; $sometext= pathinfo($sometext); print_r($sometext); ?>
-
<?php $a = '2 = 3 and 5 != 5'; preg_match_all('/(<=)|(>=)|(!=)|(=)/', $a, $b); print_r($b[0]); ?>
-
preg_match('/friendid=([^&]*)/i',$sometext,$out); or <?php $sometext = "site.com/viewprofile.cfm?blah=yay&friendID=12828&mytoken=dsf22d23d"; $sometext=parse_url($sometext); parse_str($sometext['query'],$out); $out=array_change_key_case($out); $friendid = $out['friendid']; echo $friendid; ?>
-
if $sometext isn't url try <?php $sometext = "site.com/viewprofile.cfm?blah=yay&friendid=12828&mytoken=dsf22d23d"; preg_match('/friendid=([^&]*)/',$sometext,$out); $friendid = $out[1]; echo $friendid; ?>
-
run $result = mysql_query('SHOW GRANTS FOR CURRENT_USER'); $row = mysql_fetch_row($result); echo $row[0]; to see your grants
-
change to echo $row['picture'] ? "<img src=" . $row['picture'] . " class=newsimages>" : '';
-
i use this algoritam <?php echo "<table>\n"; $num_col = 4; while ($row = mysql_fetch_array($result)){ echo "<tr>\n"; echo "<td>",$row['data'],"</td>\n"; for ($i = 1; $i < $num_col; $i++){ if ($row = mysql_fetch_array($result)){ echo "<td>",$row['data'],"</td>\n"; } else { echo "<td> </td>\n"; } } } echo "</table>\n"; ?>
-
Passing one number returned from a list to a new page
sasa replied to nyamanza's topic in PHP Coding Help
in part[code]<input colspan="0" type="hidden" name="order_id" > you must add value propertiy <input colspan="0" type="hidden" name="order_id" value="<?php echo $variable_with_id_here; ?>" >[/code] -
try <?php // let $start_period and $end_period is start and and date for payment period $start_perod = '2008-01-01'; $end_period = '2008-01-31'; $sql = "SELECT name, sum(`end time 1` + `end time 2` - `start time1` - `start time 2`) as hours, hours * rate as many FROM hours LEFT JOIN payrate ON `start date` <= `date` AND `end date` >= `date` WHERE `date` >= '$start_perod' and `date` <= '$end_period' GROUP BY `name`"; mysql_connect('localhost','root') or die(mysql_error()); mysql_select_db('name_of _your_db') or die(mysql_error()); $result = mysql_query($sql) or die(mysql_error()); while ($row = mysql_fetch_assoc($result)){ echo $row['name'],' work ',$row['hours'],' h -->',$row['many'], " €<br />\n"; } ?>
-
what is tormat of date fields in both tables what is in field `end date` in table`payrate` from current rate
-
are you talk about query (pull out data from database) or procesing data that puled before
-
error means that sql string 'test' use as field name `test`
-
in mysql change '[' and ']' with '`' and '!' with '.'
-
[SOLVED] "Delete Selected" not submitting
sasa replied to liamloveslearning's topic in PHP Coding Help
if field id in your table messages_test is primary key you can remove < AND reciever='$user'> from sql and it works with both forms -
[SOLVED] "Delete Selected" not submitting
sasa replied to liamloveslearning's topic in PHP Coding Help
move this line to the end header("Location:member_inbox_2.php"); -
[SOLVED] "Delete Selected" not submitting
sasa replied to liamloveslearning's topic in PHP Coding Help
where you start and end form? (tags <form></form>) where you proces form -
$selected = isset($_POST ['date']) ? $_POST ['date'] : mysql_result($result,0,"EndDate"); // add this line check is posted some value and setup $selected variable (if it not set $selected is result of 1s row) if(!isset($_POST['currency'])) $_POST['currency'] = 'USD'; //add this line same for another posted variable, btw. you don't need to check isset variable $_POST['currency'] is set for shure that is it
-
create two tables one from forms (form_ID, date, user, etc.) and 2ns from values (ID, form_ID, data, etc.) join them on form_ID
-
try <table> <tr> <td>Promotion</td> <td>Course Type</td> <td>Location</td> <td>Prices in THB for: <form name="form1" method="post" action="<?php echo basename($_SERVER['PHP_SELF']); ?>"> <select name="date" onchange="document.form1.submit()"> <?php //PULL DATE SELECTION OPTIONS FROM DB //1. Connect to database mysql_connect ("localhost" , "databaseadmin" , "password") or die ('Error: ' . mysqlerror()); mysql_select_db (databasename); //2. Pull date info from coursetable $query="SELECT DISTINCT StartDate, EndDate FROM coursetable WHERE EndDate > now() ORDER by StartDate ASC"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close (); //3. Display info in dropdown menu $i=0; $selected = isset($_POST ['date']) ? $_POST ['date'] : mysql_result($result,0,"EndDate"); // add this line while ($i < $num) { $startdate=mysql_result($result,$i,"StartDate"); $enddate=mysql_result($result,$i,"EndDate"); //create variables to format db dates for display $display_startdate = date('j M Y', strtotime($startdate)); $display_enddate = date('j M Y', strtotime($enddate)); //$selected = $_POST ['date']; // remove this line echo "<option value=\"$enddate\""; if($enddate == $selected){ echo " selected=\"selected\">"; } else{ echo ">"; } echo "$display_startdate to $display_enddate</option>"; $i++; }; ?> </select> </td> <?php //CREATE 2nd DROPDOWN FOR CURRENCY CONVERSION $exchangerates = array ( 'USD' => 31, 'EUR' => 48, 'GBP' => 62, 'SGD' => 21, 'MYR' => 9, 'AUD' => 28, 'HKD' => 15, 'SEK' => 6 ); ?> <td> <?php if(!isset($_POST['currency'])) $_POST['currency'] = 'USD'; //add this line ?> Approx price in <select name="currency" onchange="document.form1.submit()"> <option value="USD" <?php if ($_POST['currency'] == 'USD') { echo 'selected="selected"';} ?>>US $</option> <option value="EUR" <?php if ($_POST['currency'] == 'EUR') { echo 'selected="selected"';} ?>>Euro</option> <option value="GBP" <?php if ($_POST['currency'] == 'GBP') { echo 'selected="selected"';} ?>>GB £</option> <option value="SGD" <?php if ($_POST['currency'] == 'SGD') { echo 'selected="selected"';} ?>>SGD</option> <option value="MYR" <?php if ($_POST['currency'] == 'MYR') { echo 'selected="selected"';} ?>>Ringgit</option> <option value="HKD" <?php if ($_POST['currency'] == 'HKD') { echo 'selected="selected"';} ?>>HK $</option> <option value="AUD" <?php if ($_POST['currency'] == 'AUD') { echo 'selected="selected"';} ?>>AUS $</option> <option value="SEK" <?php if ($_POST['currency'] == 'SEK') { echo 'selected="selected"';} ?>>SEK</option> </select></form></td></tr> <?php $currency = $_POST ['currency']; $exrate = $exchangerates [$currency]; //CREATE TABLE ROWS BASED ON SELECTION FROM DROPDOWNS //1. Connect to database again mysql_connect ("localhost" , "databaseuser" , "password") or die ('Error: ' . mysqlerror()); mysql_select_db (databasename); //2. Pull info based on selected date from the table $query="SELECT CourseType, Price, Location, Promotion FROM coursetable WHERE EndDate = '$selected' ORDER by Price ASC"; $courseinfo=mysql_query($query); $num=mysql_numrows($courseinfo); mysql_close (); $i=0; while ($i < $num) { $coursetype=mysql_result($courseinfo,$i,"CourseType"); $price=mysql_result($courseinfo,$i,"Price"); $location=mysql_result($courseinfo,$i,"Location"); $promotion=mysql_result($courseinfo,$i,"Promotion"); $newprice=$price/$exrate; echo "<tr><td>$promotion</td><td>$coursetype</td><td>$location</td><td>$price</td><td>".round($newprice); echo "</td></tr>"; $i++; }; ?> </table>
-
it's work OK for me
-
array_search() function
-
change do { $css_file$int_val1 = $_POST["css_name$int_val1"]; echo "<link rel='stylesheet' href='$css_file$int_val1' type='text/css'>\n"; $int_val1++; } while ($int_val1 != $css_num); to do { $css_file = $_POST["css_name$int_val1"]; echo "<link rel='stylesheet' href='$css_file' type='text/css'>\n"; $int_val1++; } while ($int_val1 != $css_num);
-
print "Teamname : \"$_POST[teamname]\" </ br>";
-
change line if (!(isset($pagenum))) to if (!(isset($_GET['pagenum'])))