![](https://forums.phpfreaks.com/uploads/set_resources_1/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
ayok
-
Posts
340 -
Joined
-
Last visited
Never
Posts posted by ayok
-
-
Thanks for your reply, Jacob. But it still doesn't work. I think The if statement I made is wrong.
Anyone help?
-
Hi,
I found a calendar script from a tutorial in this site. I combined it with mysql query so that I can put events into the database. So if i click on a date where there is an event, the title and description of the event will occur.
The problem is, I need to mark the date which has event in it. I tried to add color to the date's column, but it didn't work.
Here is a part of the code where the dates are shown:
<?php if (!isset($_REQUEST['date'])) { $date = mktime(0, 0, 0, date('m'), date('d'), date('Y')); } else { $date = $_REQUEST['date']; } $day = date('d', $date); $month = date('m', $date); $year = date('Y', $date); $today = date("D", $date); // Get the first day of the month $month_start = mktime(0, 0, 0, $month, 1, $year); // Get friendly month name $month_name = date('M', $month_start); $month_start_day = date('D', $month_start); switch ($month_start_day) { case "Sun": $offset = 0; break; case "Mon": $offset = 1; break; case "Tue": $offset = 2; break; case "Wed": $offset = 3; break; case "Thu": $offset = 4; break; case "Fri": $offset = 5; break; case "Sat": $offset = 6; break; } if ($month == 1) { $num_days_last = cal_days_in_month(0, 12, ($year - 1)); } else { $num_days_last = cal_days_in_month(0, ($month - 1), $year); } $num_days_current = cal_days_in_month(0, $month, $year); for ($i = 1; $i <= $num_days_current; $i++) { $num_days_array[] = $i; } for ($i = 1; $i <= $num_days_last; $i++) { $num_days_last_array[] = $i; } if ($offset > 0) { $offset_correction = array_slice($num_days_last_array, -$offset, $offset); $new_count = array_merge($offset_correction, $num_days_array); $offset_count = count($offset_correction); } else { $offset_count = 0; $new_count = $num_days_array; } $current_num = count($new_count); if ($current_num > 35) { $num_weeks = 6; $outset = (42 - $current_num); } elseif ($current_num < 35) { $num_weeks = 5; $outset = (35 - $current_num); } if ($current_num == 35) { $num_weeks = 5; $outset = 0; } for ($i = 1; $i <= $outset; $i++) { $new_count[] = $i; } $weeks = array_chunk($new_count, 7); include '../../connection/db.php'; $thevents = mysql_query("select * from calendar where date_event='$date'") or die(mysql_error()); $data = mysql_fetch_array($thevents); $i = 0; foreach ($weeks as $week) { echo "<tr>\n"; foreach ($week as $d) { if ($i < $offset_count) { $day_link = "<a href=\"" . $_SERVER['PHP_SELF'] . "?date=" . mktime(0, 0, 0, $month - 1, $d, $year) . "\">$d</a>"; echo "<td bgcolor=#FFCCFF>$day_link</td>\n"; } if (($i >= $offset_count) && ($i < ($num_weeks * 7) - $outset)) { $day_link = "<a href=\"" . $_SERVER['PHP_SELF'] . "?date=" . mktime(0, 0, 0, $month, $d, $year) . "\">$d</a>"; if ($date == mktime(0, 0, 0, $month, $d, $year)) { echo "<td bgcolor=#FFFFFF>$d</td>\n"; } else { echo "<td>$day_link</td>\n"; } } elseif (($outset > 0)) { if (($i >= ($num_weeks * 7) - $outset)) { $day_link = "<a href=\"" . $_SERVER['PHP_SELF'] . "?date=" . mktime(0, 0, 0, $month + 1, $d, $year) . "\">$d</a>"; echo "<td bgcolor=#FFCCFF>$day_link</td>\n"; } } $i++; } echo "</tr>\n"; }
What is the proper if statement to mark the dates with event on it? I've tried to insert this if statement:
<?php if($date == $data['date_event']){ echo "<td bgcolor=#ff0000>$day_link</td>\n"; }
But it doesn't work.
Could someone please help me?
Thank you,
ayok
-
Hi,
I have a problem with uploading images. The script is to upload any size of jpeg with simple code:
<?php move_uploaded_file($file,"$directory_file")?>
. I don't put any validation for the size of image, because the file will be resized and the original image will be deleted immediately. However, I cannot upload a 3000px image but no problem with 1600px image.
My question is, how can I know the limit size for uploaded image?
Thank you,
ayok
-
Hi,
I make an online form which is sent the data to database and my email. There are about 10 questions like name, surname, birthday, and textarea for message. For some fields, i put js validation ask that some fields has to be filled in. Furthermore, I put this script:
if (eregi('http:', $msg)) { die ("Send us no link! ! <br><a href='index.php'>back</a>"); }
So the textarea cannot be filled with a link to other website.
My question is, do I still need to use captcha in order to avoid spam? I am afraid some visitors will be annoyed by captcha.
Thank you,
ayok
-
Super!!
Thanks fenway,
ayok
-
Hi,
I have 3 tables:
1. order_list(order_id,prod_id,quantity)
2. buyer(order_id,buyer_name)
3. products(prod_id,prod_name)
I want to make a table with which contain those datas:
buyer_name, prod_name, and quantity
What should be the mysql query for this?
Thank you,
ayok
-
yes, I mean the emails have been already in my database.
-
I mean like when we register to a forum, we need to activate by click on a link in email for confirmation.
-
Hi, Happy New Year 2008
I have a question. Is there anyway that I can use php/mysql to detect from what email address the link is clicked?
I mean the visitors of a web page are only the people who have their email address in my mysql database.
I want to give a link to some people i know by email, and nobody else can visit, but I don't want them to type username, password, etc. Is it possible?
Thank you,
ayok
-
Thank you. I've changed sum with SUM. But it still doesn't work.
ayok
-
Hi,
I have this table
id total
1 34
1 32
1 45
2 64
2 54
etc.
I want to sum the column total based on the id. So I made this mysql query.
<?php $sum = ("SELECT SUM(total),id FROM list GROUP BY id") or DIE(mysql_error()); $total = mysql_fetch_array($sum); echo $total['sum(total)'];
But I've got blank result.
Could anybody tell me what's wrong?
Thank you
ayok
-
Very Cool!
Thanks,
ayok
-
Hi,
I've been trying to insert some datas into mysql problems with this code:
<?php $enter="INSERT INTO order(prod_id,quantity,subtotal) VALUES('$ses_id','$ses_quan','$subtotal')"; $input=mysql_query($enter) or die(mysql_error()); ?>
But i keep getting this error msg:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order(prod_id,quantity,subtotal) VALUES('29','4','136')' at line 1Would anybody tell me where the mistakes?
Thank you
ayok
-
Hi,
I'm trying to make a simple online shop where we can add the products to a shopping cart. So, the visitors choose the products and can view the product on a basket. The table will show the quality, name and total price.
The problem is I got 2 extra rows with 2 qualities, 0 price and no product, above the selected products rows. I can't delete those either. This is the basket.php script:
<?php include "functions_cart.php"; $totalvalue = 0; session_start(); if (!isset($_SESSION["cart"])) { $_SESSION["cart"] = NULL; } if (validate() == TRUE && $_SESSION["cart"] != NULL) { foreach ($_SESSION["cart"] as $key => $session_data) { list($ses_id, $ses_quan) = $session_data; db_connect(); $sel_products = mysql_query("SELECT * FROM $mysql_tablename WHERE prod_id=".$ses_id.""); $item = mysql_fetch_array($sel_products); $totalvalue = $totalvalue + ($item["price"]*$ses_quan); $subtotal = ($item["price"]*$ses_quan); ?> <tr> <td><a href="<?php echo "phpCart_manage.php?act=del&pid=".$ses_id; ?>">delete</a></td> <td><input name="newquan[]" type="text" id="newquan[]3" value="<?php echo $ses_quan; ?>" size="5" maxlength="4"> <input name="eid[]" type="hidden" id="eid[]" value="<?php echo $ses_id; ?>"></td> <td><?php echo $item["title"]; ?></td> <td><?php echo $cur_symbol."".number_format($item["price"], 2, '.', ''); ?></td> <td><?php echo $cur_symbol."".number_format($subtotal, 2, '.', ''); ?></td> </tr> <?php } } elseif ($_SESSION["cart"] == NULL) { echo "<td colspan=\"5\"><center><p>Your basket is currently empty.</p></center></td>"; } else { echo "<td colspan=\"5\"><center><p>Unknown Error.</p></center></td>"; } ?>
Would anyone see what's possibly wrong?
Thank you,
ayok
-
How can I be so stupid
Thanks,
ayok
-
Hi revraz,
What I'm trying to achieve is that to have new datas on my table. There is a form with check boxes (name='pick')for sending the datas.
Here is the whole update.php:
<?php $id_temp = $_POST['id_temp']; $pick = $_POST['pick']; $label_temp = $_POST['label_temp']; $codes_temp = $_POST['codes_temp']; include "../../connection/db.php"; $delete=mysql_query("DELETE * FROM form"); $input=mysql_query($delete) or DIE(mysql_error()); foreach($pick as $id_temp){ $select=mysql_query("SELECT * FROM temp_form WHERE id_temp = '$id_temp'"); while ($data=mysql_fetch_array($select)) { $label=$data[label_temp]; $codes=$data[codes_temp]; $input=mysql_query("INSERT INTO form(picked,label,codes) VALUES('$id_temp','$label','$codes')") or DIE(mysql_error()); } } if($input) { header("location:../../form/form.php"); } else { echo "failled!"; } ?>
If i don't use this codes
<?php $delete=mysql_query("DELETE * FROM form"); $input=mysql_query($delete) or DIE(mysql_error()); ?>
I can insert new datas after I delete the old datas manually from phpmyadmin. But with those codes i keep getting error message: Query was empty.
-
Where do you assign data to these variables?
$picked,$label,$codes
I made a form which send the value of those variables to be inserted to the table. I can insert those to the table without deleting the old data's first. But I need to delete the old first.
Thanks
ayok
-
Hi,
Is it possible to update the whole rows on a table with UPDATE table SET?
I would like to replace some data's in a table with some new data's. Thus, the old datas should be all removed and new datas are inserted. I've tried to delete all data's first and entry some new data's, but it doesn't work. I keep getting "Query was empty" error message.
Here is my try:
<?php include "../../connection/db.php"; ............ $delete=mysql_query("DELETE * FROM form"); $input=mysql_query($delete) or DIE(mysql_error()); ............ $input=mysql_query("INSERT INTO form(picked,label,codes) VALUES('$picked','$label','$codes')") or DIE(mysql_error()); if($input) { echo "success"; } else { echo "failed!"; } ?>
Anyone help?
Thank you,
ayok
-
Ehm..
Let's say in the mysql table
Id name
1. John
2. Mario
3. Ben
How can I switch Mario into #1 and John #2?
Thanks,
ayok
-
Hi,
For example, I have this table on mysql
Name Age
John 35
Mario 23
Ben 24
How can I move Mario up or down in php? Is it possible?
Thank you
ayok
-
Ah... Thank's a lot shocker-z!
I missed that!
Thank you,
ayok
-
Hi,
I've made a multiple images upload php scripts. It will show 5 upload field, and if it's submitted and processed, it will show the uploaded images with input text field to fill in the title of the pics.
However, when it shows the uploaded pics, it always show one field more which is empty. So it shows 6 field, not five. Moreover, If I only upload 3, the rest still shows up. Thus, there are 3 empty fields. The result, I got 3 empty fields on my database (which I need to delete).
Here is my multiple upload script:
<?php echo"<form enctype='multipart/form-data' action='newpics.php' method='POST'>"; for($i=0;$i<5;$i++){ $no=$i+1; echo "File $no: <input type='FILE' name='fupload[]'><br><br>"; } echo "<br><input type='SUBMIT' value='Add'"; echo "</form>";?>
And it's processed and shown in newpics.php:
<?php $fupload = $_FILES['fupload']['tmp_name']; $fupload_name = $_FILES['fupload']['name']; $fupload_type = $_FILES['fupload']['type']; echo "Uploaded files:<br><br>"; $images=count($fupload); $i=0; echo "<table>"; while($i <= $images) { $direktori_file = "../../gallery/images/original/$fupload_name[$i]"; ...... resize scripts........ echo "<form action='inputdata.php' method='GET'><tr><td><img src='$thumbnail'></td><td rowspan=2><INPUT TYPE=TEXT SIZE=30 NAME= descript[]></td></tr>"; echo "<tr><td>$fupload_name[$i]<input TYPE=hidden name=fupload_name[] value='$fupload_name[$i]'></td></tr>"; $i++; } echo "</table><INPUT TYPE=SUBMIT VALUE=Add Info></form>";?>
Could someone tell me how can I exclude the fields that I don't need?
Thank you,
ayok
-
anyone?
-
i stoped uniform server and started wamp, seems nicer, started the apache service, server is online php file is in www directory, still not working
You have to save your php files on folder htdocs, and open it.
CSS problems on browsers
in CSS Help
Posted
Hi,
I am quite new for CSS. Mostly I use table to structure a webpage which is for me easier. But something I don't like with table, so I learn CSS now.
However, I got some problems with CSS.
I have the picture below in opera. It looks fine.
The css is as follow for the content and navigation:
So the navigation width is 20% and the content 78%.
However in IE it looks like this:
The content is below the navigation. How can I fix it?
And I've been trying to make the hight of the navigation always the same height with the content.
How can I possibly do that?
Thank you,
ayok