smantscheff 265 Veteran Poster

I assume that with "title" you refer to the contents of the h2 tag.


$text = '<div class="dealsListS">
<h2>contents</h2>
<div class="thumbWrapper">images</div>
</div>';

preg_match( '~<div class="dealsListS">\s*<h2>(.*?)</h2>\s*<div class="thumbWrapper">(.*?)</div>\s*</div>~is'
	, $text, $matches 
);
$title = $matches[1];
$thumbs = $matches[2];
smantscheff 265 Veteran Poster

Precede p_id by the table and the database name:

where db1.t1.p_id=db2.t2.p_id and db1.t1.p_id=db3.t3.p_id
smantscheff 265 Veteran Poster

You can use the group_concat() function:

SELECT code, COUNT( code ), group_concat(data) AS no_of_times
FROM testing_table
GROUP BY code
ORDER BY code
smantscheff 265 Veteran Poster

It is not clear which part you want eventually to match. Do you want to replace css classes?
The first three preg_match statements are better put in one single statement to clarify the code. But first tell us which part you want to have extracted.

smantscheff 265 Veteran Poster

What is your problem? Where are you stuck?

smantscheff 265 Veteran Poster

If divs are not nested you get them with the code from your first post (after fixing the quotes): ~<div class='name'\>(.*?)</div>~s

smantscheff 265 Veteran Poster

(<div.*?</div>\s*) matches until the first </div> . Therefore you cannot tackle nested divs (or other nested tags) with it. Use a recursive or parse function for that.

smantscheff 265 Veteran Poster

Wouldn't it make your database more efficient if you stored the image file in the server and just stored the image's address in the database instead?

You don't make your database more efficient with not storing pictures in it. That is rubbish. You make it more efficient by good design and careful indexing. There are lots of good reasons to have images in the database, one being coding efficiency.
Your upload code is wrong. To load pictures into the database you have to upload them as a file with your $_POST array containing the file name. Then you can read it from the local server into a variable and feed it to the mysql server. Google for "PHP file upload".

smantscheff 265 Veteran Poster

Please mark this thread as solved - if it is.

smantscheff 265 Veteran Poster

What does "does not work" mean? If the function mysql_result() does not work in your installation, you might have to start with a new system.
With a closer look you might have noticed that I missed a parameter in mysql_result. Try mysql_result($result, $r, $i) , then my code should give you the desired array.

smantscheff 265 Veteran Poster

Regular expressions do not work recursively. To match arbitrarily deeply nested div tags you would need such an recursion. You could use a regex for this special case like this:

preg_match_all('~<div class=\'name\'>\s*(<div.*?</div>\s*)?(.*?)</div>~is', $res, $matches );
smantscheff 265 Veteran Poster

What do you mean with "partially upload"? Does part of them get into the database? Show the receiving script and the CREATE TABLE statements for the images table.

smantscheff 265 Veteran Poster

A clean solution would require two repair tables: repairs and repair_items. A repair is completed if all of its items are completed. Then it's the user's choice to assign an item to a repair.
Again: show the CREATE TABLE statements.

smantscheff 265 Veteran Poster

Find a free or paid SMS service. They will have usually HTTP GET interfaces so that you can build a HTTP query string which contains your user's phonenumber and payload.

smantscheff 265 Veteran Poster

Assuming completed is a boolean field you can select the boolean and of all completed fields for one customer like that:

select (sum(if(completed,1,0)) - count(*)) as all_completed from repairs where customer_id=$fixed_value

If all_completed is 0, all repair has been done.
For further discussion please provide the CREATE TABLE statemens of the involved tables.

smantscheff 265 Veteran Poster

You have the customer_id. This is link enough. You can select all repairs for one customer using the customer id, and for formatting purposes you can use the group_concat() function, like in

select group_concat(repair_id) from repairs where customer_id=$fixed_value;
smantscheff 265 Veteran Poster

What are "edit dates"?
And no, the comparison operators < = > in PHP do string or numeric comparison but not date formats. So you have to format the dates to be compared in the order Y-m-d H:m:i.

smantscheff 265 Veteran Poster

Why can't you generate the tab content from the database?

smantscheff 265 Veteran Poster

The method is: learn, try, test, develop, learn some more. Thst's how it can be done. Give it at least a try.

smantscheff 265 Veteran Poster

You sure have a unique id field in the modul table which you could use to form an anchor, like in <a href="#tabs-$result['id']">$result['nama_modul']</a> Apart from that, the php code tags are missing in line 9.

smantscheff 265 Veteran Poster

For god's sake, where is the problem? (Did you notice that this here is a PHP forum, not for JavaScript? And did you notice that you are not only allowed, but supposed to use code tags?)

smantscheff 265 Veteran Poster

You're welcome. But what do you need? Can't you do the math?

smantscheff 265 Veteran Poster

It is a question of code efficiency. You use functions 1) to avoid code repetitions and 2) to make the semantics clearer. If the function is only called one during initialization and you will not use the result at another place, don't store it in a property. If on the other hand the function will be called more than once it is good practice to store the result for re-usage, especially if this is a costly function.

smantscheff 265 Veteran Poster

Compare the filetimes, then format the one you want to have.

$format = 'm/d/Y H:i:s';
if ($t1 = filemtime('page1.php') < ($t2 = filemtime('page2.php'))
  $filetime = date( $format, $t2 );
else
  $filetime = date( $format, $t1 );
smantscheff 265 Veteran Poster

Is this a question of speed, readability, maintainability or what? You can do it either way as long as you are happy with it. There is no standard way because your database design is flawed.
Since placements for the same url are unique (you cannot have sideadmiddle more than once for the same url, or can you?) you should have fields called sideadtop, sideadmiddle etc. Then your problem would go away: you would only select one row per url.

smantscheff 265 Veteran Poster

I don't understand the problem. You know how you can get column names using mysql_field_name(). You also know how to get the field content using mysql_result. Put both together to create any array you want. For example (not tested):

for ($i = 0; $i < mysql_num_fields($result); $i++)
  $columnNames[] = mysql_field_name($result, $i);
for ($r = 0; $r < mysql_num_rows($result); $r++)
  for ($i = 0; $i < sizeof($columnNames); $i++)
    $myResultTable[$r][$columnNames[$i]] = mysql_result($r, $i);

It that's not what you want, how would your desired result look like?

smantscheff 265 Veteran Poster

Extract the content you want using regular expressions and store it in a (MySQL) database. You can do that with PHP or any other language with a regular expression module.

smantscheff 265 Veteran Poster
SELECT CustomerName 
FROM Customer 
WHERE NOT (Customer.CustomerCode in 
(SELECT c.CustomerCode
 FROM Customer c, Movie m, Video v
 WHERE c.CustomerCode = v.CustomerSoldTo
 AND m.MovieCode = v.MovieCode
 AND m.Rating = 'R'
))
smantscheff 265 Veteran Poster

What' your problem?

smantscheff 265 Veteran Poster

Well Internet Explorer have always had its special ****ed way of doing things, and this is the header it actually sends for JPG files, while all the other browsers send "image/jpeg"

How does Internet Explorer send headers? For JPG or any other files? To whom?

smantscheff 265 Veteran Poster

I cannot resist ardav's challenge for a 2-liner. This is not a 2-liner, but at least it has 2 lines less than ardav's solution (which is a fine start to begin with).
Just add 4 weeks to your start date. If this does not bring you into the next month, add another week.
Code not tested.

//GET THESE SENT FROM A FORM and possibly parsed/exploded
$start_year = 2011;
$start_month = 3; // (1 = Jan, etc, so 3 = March)
$num_months = 6;
$repeat_day = 3; //(0=sun,1=mon etc, so weds = 3)
$calendar_info = "this, that and the other"; //event details


$date = mktime(0,0,0,$start_month, $start_day, start_year );
for ($x = 0; $x < $num_months; $x++)
  $date_clauses[] = sprintf("'%s','%s'", date('Y-m-d', $date), $calendar_info );
  $date += 4 * 7 * 24 * 3600; // increment date by 4 weeks
  while (month($date) == ($start_month + $x) % 12) // if we are still in the same month
    $date += 7 * 24 * 3600; // add another week
  }
  $date_clauses[] = "('$date_event','$calendar_info')";
}
$date_clause = implode(",",$dateclauses);
$r = mysql_query("INSERT INTO events (`date`,`event_details`) VALUES $date_clause");
smantscheff 265 Veteran Poster

If with "traditional SQL statement execution" you mean Data Manipulation Language only, be pleased to find that MySQL supports all Data Definition Language statements through its standard interface, too, and they can arbitrarily be mixed. Which means: anything which you can achieve using the MySQL command line interface you can also achieve using PHP. Therefore I strongly recommend the use of the command line (as opposed to using GUIs which do their job fine but won't let you learn how to do it on a lower level).
My code does not refer to any PEAR modules; it's plain PHP.

smantscheff 265 Veteran Poster

What does $View contain in your query?
In these lines the replacement ', ' by ',' can never occur because all blanks have already been replaced before.

$replace_what = array('  ', ' - ', ' ',    ', ', ',');
$replace_with = array(' ', '-', '_', ',', '-');
smantscheff 265 Veteran Poster

If you do not know how to create a MySQL insert statement from PHP I suggest that you google for "mysql php primer" and take a course first.
Any command which you enter on the mysql command line you can also put into a PHP variable and feed to mysql - with exactly the same effects. You could for example create a table from a field definition array (not tested):

$fields = array( 
  array( 'id', 'integer', false, 'auto_increment primary key')
, array( 'username', 'varchar(255)', false, NULL)
);
$create = '';
foreach( $fields as $field) {
  $create .= ",$field[0] $field[1]";
  if (!$field[2]) $create .= ' not null ';
  if ($field[3]) $create .= $field[3];
}
$create = 'CREATE TABLE users (' . substr($create, 1) . ')';
mysql_query( $create );
smantscheff 265 Veteran Poster

I don't konw if it can be done from MySQL itself, that is, from procedures or triggers. But it definitely can be done with any language (like PHP) which lets you synthesize mysql commands. What is your programming platform?

smantscheff 265 Veteran Poster

Start with a clean database design which does not contain structural duplicates. You do not need one table for each quiz, but one table each for quizzes, questions, answers, users, users_and_answers.
First do all your database work and see if you store and retrieve all necessary info. Then move on to designing and implementing the interface.

smantscheff 265 Veteran Poster

You got your quotes wrong.
Change

$query = "SELECT * FROM players WHERE UID='$uid';

to

$query = "SELECT * FROM players WHERE UID='$uid'";

And use a decent editor with syntax highlighting. I recommend EditPad++.

smantscheff 265 Veteran Poster

Where do you define $font and $fontsize?

smantscheff 265 Veteran Poster

And where is the problem?

smantscheff 265 Veteran Poster

How far have you got already? Show your code.

smantscheff 265 Veteran Poster

Use array_merge().

$variable3 = array_merge( $variable1, $variable2 );

And check your code style. With your kind of ungrammatical writing and spelling you will spend more time debugging than coding.

smantscheff 265 Veteran Poster

You can check the HTTP_POST_FILES array for the actual file size and gracefully reject larger files. There is also a PHP setting max_upload_size which can limit the upload size with a maybe not so user-friendly error message.
The uploaded file can be converted with the GD image library. Or install ImageMagick and use a system() call for external conversion.

smantscheff 265 Veteran Poster

You already have an AFTER UPDATE trigger ON takes in your database.

smantscheff 265 Veteran Poster

If you are using PHP, you can use exactly the same DDL statements as from the command line. So, yes, you can dynamically create and alter tables.

smantscheff 265 Veteran Poster

So what? In which ecospace is this problem at home? Do you want to solve it interactively, or in a trigger, or in PHP script, or by means of smoke signals?

smantscheff 265 Veteran Poster

You can protect the phpmyadmin directory with an .htaccess containing the statements
AuthType Basic
AuthName "Restricted Files"
AuthUserFile path/to/your/password/file
Require user /your/username
Have a look: http://httpd.apache.org/docs/2.0/howto/auth.html

In the phpmyadmin is an index.php file to which the empty request / defaults.

smantscheff 265 Veteran Poster

My first suggestion is that you explain your problem. What do you want?

smantscheff 265 Veteran Poster

Try order by 0 + hour

smantscheff 265 Veteran Poster

Use backticks for column names instead of apostrophes (or omit them if your column names don't contain blanks), but use apostrophes around the field content. Do not use a semicolon inside the statement if you submit it using PHP.

$sql = "INSERT INTO `comments` (user ,pass,comment) VALUES ('$user', '$pass', '$comment')";
smantscheff 265 Veteran Poster

Show the code. Are you updating the database at all?