Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Use Strcmp To Edit A Dynamically Generated Dropdown...


I've written a code that runs a 'SHOW DATABASES' query on my mysql server and lists the results(the names of the databases on my server) in a dynamically generated dropdown box, and it works just fine, using the following code:

echo "<select name='databaseselect'>";
$dblist = mysql_query('SHOW DATABASES');
while ($row = mysql_fetch_row($dblist)) {
echo "<option value='$row2[0]'>$row2[0]</option>";
}
echo "</select>";

The problem is that it lists ALL of the databases on my server - that's two of my own user-created databases, and the two default databases that come with the mysql server - 'information_schema' and 'mysql'.  What I want to do is to, after running the 'SHOW DATABASES' query, eliminate those two databases from appearing in the dropdown box, because I don't want anyone to see them, as they're useless to anybody else. Code:




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Dynamically Generated Results Table
I'm trying to write a script that dynamically generates HTML tables depending on the results from an SQL query. So far, I have managed to set the HTML table headers to be the same as those in the MySQL table. [thanks to rod k -cheers !]

Now i'm trying to put the results in the table. Basically, I need a MySQL function to retrieve data and put it into the table until there is no data left....

(At the moment I am using "mysql_fetch_array()", but with this it is necessary to know the names of the columns to retrieve the information for each result set. Since my table is dynamic and should be able to build itself from different MySQL tables, the column names aren't fixed and so i can't use this to put the data in the tables...)

Getting Dynamically Generated POST Data
I'm trying to get POST data that was dynamically generated and I'm not sure how to go about doing this.

Populating Dynamically Generated TextFields
If one assigns something to the value iattribute off an input /text field, that value will be displayed when the form is loaded. My problem is, when building a form dynamically, the only way I can get the text to show is by doing the above, however, as this is an update form, when the form POSTS to processUpdate.php,
both the data entered by the user AND the data in the value attribute are inserted/updated.

So, how does one dynamically build a form where the data is displayed in the text fields but value atttribute is not set. PHP Code:

Highlight Dynamically Generated Text
I have a search form which makes queries to a database. In the form the user can search for many words (word1 && word2 && word3). I want in the results to highlight the words that the user has searched for. I 've searched in the internet and i've found some codes but none of them works with all the possible results.

What I have found so far which is closer to what I want is the following:

Uploading A Dynamically-generated Image
I have a script that generates an image based on users' inputs. How would I make it so that the script automatically uploads that image to a different folder on the server? I'm stumped on this one. Does anybody have any ideas?

Dynamically Generated Form And Update Problems
In brief, in the following 2 portions of code I build a form based on data retrieved from a database. The second bit of code receives the posted data for processing and updating the database. Problem is that the update occurs for the first row of data but none of
the rest. I'm using a hidden field, written in dynamically (
name="tfHiddenId<?php echo $j ?>" ) where $j is a counter var in a loop.

When I print out the POST_VARS everything is as I want to be, fields all
named according ly, as above. Just the update either 1) only does one
row and quits or 2) updates same row with the same data over and over ( I
suspect the latter ). Apparently my counter variable is not being incremented, but only on one var, "tfHiddenId".$i , on the receiving page. Here's the code for where the form is built from the DB: PHP Code:

Multiple Submit Buttons In Dynamically Generated Form
I have one big form on a page, within which is a list of text fields pulled from a mysql db. Each text field has an 'update' button, which submits the main form, and should UPDATE the textfield it relates to.

The problem is, all the buttons have value="Update" and I can't think of an efficient way of passing the unique id of each record to be submitted with it. Obviously, having a hidden field for each textfield won't work because the form will use the last one displayed.

[PEAR:QuickForm] Dynamically Change A Dropdown Menu According To Another Menu?
I've been using QuickForm for a few months now and I am now given a
new challenge:

I've got a search form with a dozen of dropdown menus, the first
dropdown menu being "Brand". If you select either Brand A, B, C, D...
Z, the second dropdown menu "Model" must be dynamically changed to
model AA, AB, AC, AD..., according to the models manufactured by the
brand selected in the first box.

I've seen that done on quite a few sites, but never found if QuickForm
had a quick & clean way of doing that.

Dynamic Dropdown And Hardcode Dropdown In Select Form
I have plenty of examples of dynamic dropdown choices but none of hardcoded dropdown choices. The ultimate goal is to have a job with various tasks and to track the status of those tasks for a given job. I've used one of the tutorials here to begin the process. Below is the code I have to add work on a given task. Perhaps I actually need to "Update" a job as opposed to "add".

But the problem of the moment is I can't seem to hardcode one set of my options. This is the code I have: PHP Code:

Strcmp Problem
I done a program to read text file, where content is

#Header#
name: Juicy
age: 25
@Header@
#Text#
user text here
@Text@
#End#
tel
fax
@End@
eof

And I read the text file

$filename = "/usr/local/file/rpt.txt";
$fp = fopen($filename, 'r');

$content = fgets($fp);
while(strcmp($content,"@End@")<>0) {

$content = fgets($fp);

if(strcmp($content, "#Text#")==0){ //not match
$strPretext .= $content;
}//end if
//end while


I should get the data from #Text# until one line before @End@, but I get
nothing, I found that the strcmp for #Text# always not match when it read
through whole file.

Strcmp Vs Equal
I noticed in some examples to the encrypt functions of the PHP manual a
syntax was used for password checks such as

if (strcmp($userpassword, md5($_POST['password'])) == 0) {
// do login
}

What is the advantage of this compared to

if ($userpassword == md5($_POST['password'])) {
// do login
}

?

Dynamically Populate Drop-down List And Dynamically Include Html File
We have a drop down list on a PHP page, with several product names, and
when people click one item, we will refresh the same page with the
product name as parameter, and in turn we want to include a HTML file
into the content area of the same page.

I know it is recommended to put everything into database, but we want
the web site to be very "portable", so the drop-downlist and the
content should both in text files.

Let's say the drop-down list will be poplulated from the product.txt
file, and there will be a file for each corresponding item in the
drop-down list. From the user point of view, if he wants to add a new
product, he will just need to open the product.txt file, and add a new
line with the product name, "Laptop", then add a new text file named
"laptop" in the same folder which contains the HTML fragment to be
included in the content area.

What is the easiest way to do this?

Case Sensitive Comparisons With Strcmp?
I've written a mod for phpBB to give the forum admin more control over
the smilies. Part of the mod checks to make sure that no two smilies
have the same code.

code = :), :-), :D, :P, :lol:, :happy:, etc.

For some reason my mySQL code is finding a match between :D and :d, :P
and :p, :cool: and :COOL:, etc. Other than that it works fine.

$sql = "SELECT smilies_id FROM " . SMILIES_TABLE . " WHERE
smilies_id!='" . $smilies_id . "' AND code=STRCMP(code, '" .
addslashes($code) . "')";

I've just noticed that I can get around this (sort of) by comparing the
filenames as well, ie. :D and :d would be linked to the same smiley.
But I'd still like to know why STRCMP (which is case sensitive) is
finding a match between D and d.

Question On Using "strcmp" To Compare Unicode Strings
I am confused by the rule of comparing two unicode string using
function "strcmp". For exmaple, using "strcmp" to compare two Chinese uincode string, depending on what rule can "PHP" decide one string is greater or less
than the other string?

Php Script Generated By Php
I am trying generate a new PHP file from an existing page using PHP. Currently I'm using the output buffer to capture content destined for the page, and then am capturing that output and writing to a file.

The problem I am having is that all PHP scripts within the new page content are executed and the results are written to the new file, when I would like the PHP code itself to be written to the new file, unprocessed.

So now I am trying to just store the new page as a string and bypass the use of the output buffer, but do not know how to store php code within a string without having it execute...

EDIT CSS
i need a script that will allow my to edit the css file through a website. Like without going through the cPanle I could just click a link throught the site and it will allow me to edit it.

PHP Edit Itself?
Can a PHP script edit itself? And if so would it be faster to store/retrieve information this way instead of using a database? Or would it be slower?

Using Php Generated Pictures With HTML?
I am able to create images with the use of the GDLIB.
but I am not able to use these images together with HTML. I always get the
message "headers are already sent.

I Am Trying To Pipe In Some Auto-generated PHP Into Php.exe
I am trying to pipe in some auto-generated PHP into php.exe, to no
avail:

How To Farmat Php-generated Table
the font size declaration seems to be ignored. Is it possible to set format for
tables generated with php?

<?php

echo "<table border=1 font size=8>";
echo '<tr><th font size=8>Date</th>
<th>IP Address</th>
<th>Operating System</th>
<th>Browser</th>
<th>Referring Page</th>
<tr>'

?>

Getting MySQL Generated Keys
I am a Java/JSP developer by trade but am currently developing a
MySQL/PHP solution.

In JSP when I run an INSERT statement on the db I am able to
automatically get back a list of any generated keys (without having to
do some sort of subsequent query to get the information).

Is there a PHP equivilent of this?

Php-generated Png Transparency Issue In IE
I've been trying to get my page, which works perfectly in Firefox, to work in IE as well. one problem was getting the .png images to display properly, which was fixed by doing this:

filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='imagename.png')

but what of php-generated .png files? putting the php file as the src doesn't work. the php-generated images don't work at all in IE (but work fine in firefox).

(the php-generated image uses a transparent color made with imagecolorallocatealpha. when I just use imagecolorallocate it shows up, but is not transparent as I want it.)

Generated PHP Web Database Forms
I'm still gaining experiance in developing PHP applications, and have completed
a couple of projects already.

This has prompted me to look for ways to reduce the development time for web
enabled database applications. Every web database has basic operations such as
add,delete,update and search. I have been creating HTML forms and processing
the results with php code. I have managed to reduce the number of forms required
by using the smarty template engine.

I want to go a stage further and be able to produce the forms and the processing
code purely by looking at some sort of schema file , or using
"mysql_list_fields()" and "mysql_list_dbs()".

Before I start my quest of many late nights of coding. Can any of you guys
give me a head start by pointing me at a solution/hint.



Generated Images Not Printing?
I have a problem with IE and generated images (jpgraph). It displays
them fine but it's not printing them. They appear as little red crosses
in print preview.

I've fiddled with the cache control headers as I thought that was it.
Certainly IE refuses to cache pdf files sent using fpassthru and cannot
open them in acrobat.

Server Generated PDF Files?
Heres what I need to happen now, I know how to do most of it, except the generated PDF form.

- The server puts that information into a PDF file with a background of my chosing and emails it to a specified adress. (Its already set up to send the email)

My issue is I dont know how to have the server generate the PHP form. How does it work? How do I position the text over the PDF automatically?

I'm already donating $10 to the site, thanks to the help I received from UTAlan, Lytheum, and Waldir. Ill make it a total of $20 after this.

Image Src Generated Through Php File
I've built a custom image gallery, integrated with a database. all of the images are kept above the document root in a "media" directory (for security purposes); therefore, i am using a php script in the src attribute of the image tags to display the image in the browser.

to accomplish this, i chose to use the PEAR package "HTTP_Download", which worked great and performed fantastically on my staging server.  I chose to use content-disposition inline, and set caching options on.

the problem, the images don't cache on a users machine.  therefore, everytime the page is changed to display a new image, all of the thumbnails are downloaded once again...very annoying. let me re-iterate, these files are not being generated on the fly, simply sent to the user via php. Code:

Mail A Php Generated Page
I ask if it's possible to sent to email a php generated page as an html attachment or text file !?

I have searched on google, but I find only how to send mail from php not hot to send a page.

Any link, or doc is helpfull !

The story:
I have a long products list, from where I select some items what I want to send as a price list to some people.

PHP-generated RSS Feeds And .xml Files
I want to make an RSS feed for my site.  Obviously, it should be dynamic, so the only way that comes to mind is to use PHP to create the RSS.  But then the filename will be .php.  Most of the sites I see with feeds (digg, shoutwire, cnn, etc) have .xml files.  How do they do this? I would like to have a .xml that is dynamic/always up-to-date.

Looking For Dropdown Help
I have a dropdown in which i want it to open a soundfile when selected. So, how do I go about this. The form will get submitted, and through a series of conditional statements it will point the right selection to the right if statement. but what do I put in the if statement to get it to open a realplayer with my ram file?? Here's what I got so far.
Code: <FORM ACTION="<?=$_SERVER['PHP_SELF']?mode=changedropdown?>" METHOD="POST" NAME="sermondropdown">
<P>
<SELECT NAME="sermons" SIZE="1" onchange="this.form.submit();">
<OPTION VALUE="pleaseselectasermon">Please Select a Sermon
<OPTION VALUE="082403Daniel_1_1-8">August 24, 2003 Daniel 1:1-8
<OPTION VALUE="083103Daniel_1_1-8">August 31, 2003 Daniel 1:1-8
</SELECT></P>
</FORM>

<?
if('changedropdown' == $_GET['mode']) {
$selection = $_POST['sermons'];
if (?Daniel_1_1-8' == $selection) {

} elseif (?Daniel_1_1-8' == $selection) {

}
?>

Dropdown
I have a dynamic drop down that needs to be populated from different columns in a database. The problem I'm running into is that sometimes fields do not have a value. So I would rather those didn't print out. The code below prints out the blank fields.

I know I need to loop through and check for an empty value, but I'm drawing a blank on the how part. Code:

Dropdown Possible With PHP ?
i'm looking for a way to do the following :

1. selecting data from a MySQL database
2. putting one field into a dropdown
3. after selecting a value from the dropdown follow some more php code

step 1 is no problem, step 2 is no problem with the html select statement however this leaves me on the client side. After this i'm not able to return to the server side to execute some more php code, with the onchange attribute i can start some javascript but i want ( read need ) to use php code. Concrete question : is there a way to create a dropdown in pure php code ?

Dropdown Box
I currently have a dropdown box on a page. What I would like is that when a user selects something from the dropdown box it automatically changes the display of another box.

Value In A Dropdown
I have a piece of code where I get the player_id value from the url at the top of the page. Rather than this I want to get the value from variable named $player_one. Code:

Edit/replace?
How would I edit or replace a field of a row in my database?

Edit MySQL Using PHP
I know that I need to include a textbox and everything, but dont know how. In my database I would like to be able to edit it from my website that has a textbox and a button that allows it to change a field in the database and replace it with the text in the box.

Trying To Edit A Txt File
Hi I am trying to edit a text file... the format of which is like

#####abc.conf
poll somethin
proto pop3
via 127.9.02.1
user "me@me.com"
pass "dell"
is me.nutcase
preconnect "abc abc abc abc"
##
poll ak #
proto pop3
via 11.11.22.33
user "ak@bk.com"
pass "eatme"
is nutter
fetchall
preconnect "abs -e -f -f /ss/ss/ "
##

The way i am tryin to edit this file is ....

<?php
$file = "/som/thing/abc.conf"
$dele = "poll ak";
$open = fopen($file, "r+w");
$read = fread($open, filesize($file));
$sep1 = explode($dele, $read);
$sep2 = explode('##', $sep1[1]);

$read = str_replace(array($dele, $sep2[0]), array("", "
"), $read);
fseek($open, 0);
fwrite($open, $read);
fclose($open);

The result of what happens is it delete the tag from poll ak till the ##

but also adds some text at file end like ....

Resource id #2Resource id #2Resource id #2Resource id #2Resource id
#2Resource id #2Resource id #2Resource id #2Resource id #2Resource id
#2Resource id #2Resource id #2Resource id #2Resource id #2Resource id
#2Resource id #2Resource id #2Resource id #2Resource id #2Resource id
#2Resource id #2Resource id #2Resource id #2Resource id #2Resource id
#2Resource id #2Resource id #2Resource id #2Resource id #2Resource id
#2Resource id #2Resource id #2Resource id #2Resource id #2Resource id
#2Resource id #2Resource id #2Resource id #2Resource id #2Resource id
#2Resource id #2Resource id #2defaults
via 11.11.22.33
user "ak@bk.com"
pass "eatme"
is nutter
fetchall
preconnect "abs -e -f -f /ss/ss/ "

Edit Profile
I would like the user to edit their own profile. But how can I retrieve the data in the form to perform update, instead of display as the code below? PHP Code:

Read And Edit Xml With PHP
I'm trying to write some php that will read in some xml and then allow me to modify the tag and write back out to xml.

In the following example, I want to read in 'text_for_paragraph_1',
then allow it to be viewed, edited, and saved back to the xml... I
have absolutely no clue even where to start...

Php Edit Xml File
I have an xml file that looks roughly like this:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<videos>
<video url="new.flv" desc="Guitar Solo" />
</videos>

what i want to be able to do is add more entries like "<video url="new.flv" desc="Guitar Solo" />". How can I get it to add the entry into the right place, so it doesnt show up after the </videos>?

Video Edit
It is possible to upload your own video and then mix it the way you want. Is there available a php library for modifying flv videos to mix them and add effects just like in eyespot. I know for flvtool 2 but i am not sure it will do the thing and i couldnt find any documentation for it.

Allow To Edit Within X Hours
I have data that is inserted into a database, one of the fields is named 'time_stamp' and is a "datetime; 0000-00-00 00:00:00" type.

I was wondering how one could make an if statement that will show code (code is just the editing portion of the page) if the 'time_stamp' is less than the 'time_stamp' + 72 hours. Other wise, don't show the code and inform them that they can no longer edit.

Edit Regarding Check Box?
I am trying to write a little script that when the user chooses to edit there ad on the site, it will display a list of there images as thumbnails. They then check a box for the images they want to keep. Is this the correct syntax? Code:

Edit Php To Html
I have a website on a cd and is in php format.How do i change from php to html?Or what program should i use so i can publish the website.

Problems Saving Gd Generated File
I'm using the gd library to build graphs from db generated data. I can output the result to the browser with no problems, but when I try to save the image, I get the following error message.

PHP Generated Pages & Search Engines
I'm trying to get a basic idea of how well PHP generated pages can be spidered by search engines? I'm working for a company that keeps two versions of it's site at the moment. One copy run off of a database using CGI, and one copy entirely in HTML so search engines will find them. I've told them that this is just a bad idea, and far too time consuming. I'm under the impression that PHP pages can be found by search engines, am I wrong? I'm going to be running almost their entire database of products off of one file, will the search engines be able to find these if there aren't direct links to them?

Any other suggestions as to how to keep their positions in the search engines (very good right now) would be appreciated as well.

PHP 5 Compilation Error: Libphp5.so Is Not Generated
I started from a clean, new system, with only SSH and Webmin. It's a VPS running on Fedora Core release 2.

1) I added my domain name to the BIND server

2) I downloaded the last stable Apache version, 2.2.3, and installed it
using:

./configure --prefix=/usr/local/apache --enable-so --enable-module=rewrite
make
make install

3) I tested it, it worked.
4) I downloaded the last stable PHP version, 5.1.6, and installed it using
the MINIMUM configuration possible (not even MySQL):
./configure --with-apxs2=/usr/local/apache/bin/apxs
make
make install

"make install" gave me that error:
==================================

[root@server php-5.1.6]# make install
Installing PHP SAPI module: apache2handler
/usr/local/apache/build/instdso.sh
SH_LIBTOOL='/usr/local/apache/build/libtool' libphp5.la
/usr/local/apache/modules
/usr/local/apache/build/libtool --mode=install cp libphp5.la
/usr/local/apache/modules/
cp .libs/libphp5.lai /usr/local/apache/modules/libphp5.la
cp .libs/libphp5.a /usr/local/apache/modules/libphp5.a
ranlib /usr/local/apache/modules/libphp5.a
chmod 644 /usr/local/apache/modules/libphp5.a
libtool: install: warning: remember to run `libtool --finish
/root/zzz/php-5.1.6/libs'
Warning! dlname not found in /usr/local/apache/modules/libphp5.la.
Assuming installing a .so rather than a libtool archive.
chmod 755 /usr/local/apache/modules/libphp5.so
chmod: cannot access `/usr/local/apache/modules/libphp5.so': No such file or
directory
apxs:Error: Command failed with rc=65536

==================================

The problem is that libphp5.so is not generated from "make".

I found those related links:
http://www.fedoraforum.org/forum/archive/index.php/t-23665.html
http://bugs.php.net/bug.php?id=27795

Following the recommendations I tried:

1) using the bz2 version of the PHP distribution and not the gz one

2) I installed getText ( http://www.gnu.org/software/gettext/ ) because some
say an included library, "libintl.so", could help. But I couldn't find that
library after getText was sucessfully compiled.

3) I chomed everything to 777 in the php directory

4) I installed the last stable libtool, 1.5.22

Nothing worked, I still have that libphp5.so error.

Any help would be really appreciated. And I really mean it!

Are Multiple GD Generated Images Possible On One Page?
I've been experimenting with generating PNG files via PHP and GD. All was going fine, until I tried to put more than one image on a single page.

<img src="draw.php?text=Picture1"><br>
<img src="draw.php?text=Picture2"><br>
<img src="draw.php?text=Picture3"><br>

The example above produced 3 images, but they all have 'Picture3' on them. Seems like theres only 1 temp storage area for the images?

Strange File Auto Generated?
I am using Linux/PHP4 + Smarty, sometimes I found some strange file
auto generated under the temp folder for smarty cache,

e.g. phpNd7W05

Anyone know the reason for this file?

How To Handle Special Characters In RSS Generated By PHP?
I generate RSS 2.0 using PHP from mysql DB, for example:
echo "<title>" . $title . </title>";
echo "<link>" . $link . </link>";
echo "<description>" . $description . "</description>">

The problem is, sometime there are special characters in $description or $title, for example, trademark symbol. Is there a function which can remove these characters? I tried to use htmlspecialchars ($description), which only work with HTML tags.


Copyright © 2005-08 www.BigResource.com, All rights reserved