PHP - Csv Sorting By Field And View Only Selected Rows
Hello!
I been trying to figure how first read a Google docs CSV (live) to be shown as a custom HTML. The CSV have 50 lines and each line have 15 cells. With a bit searching i figure out to this : Code: [Select] <?PHP $file_handle = fopen("https://docs.google.com/spreadsheet/pub?key=0Aus5xZRHSuhydGpmcXBRN0Z2WXM5Sks3TlgydF92R1E&single=true&gid=3&output=csv", "r"); while (!feof($file_handle) ) { $line_of_text = fgetcsv($file_handle, 1024); print "<custom code>" . $line_of_text[0] . $line_of_text[1]. $line_of_text[2] . $line_of_text[3] . $line_of_text[4] . $line_of_text[5] . $line_of_text[6] . $line_of_text[7] . $line_of_text[8] . $line_of_text[9] .$line_of_text[10] . $line_of_text[11] . $line_of_text[12] . $line_of_text[13] . $line_of_text[14] . $line_of_text[15] . "<br>"; } fclose($file_handle); ?> But what i would need is to view only the row that have the value "(T01S)" in the first cell "A2" or first "$line_of_text[0]" and the header (first line). I was thinking about just to show a "desired_line" would not help me as if i add a line in the middle many pages would show the wrong line. Also is it any easy way to show one full line except the first cell? So i can have a custom code on that field? And also so i do not need every pages code if i add more fields? After many hours of searching i would be very happy for any kind of help! Similar TutorialsHi first tyvm for reading my help request me and my friend ar trying to build a order form (see png file ^^) so the main idea is some on go to order form.php
in that order form they fil in thear info like name, adress you know ^^
thean here is the treaky part at the and of the form they kan add products to there order by selecting it or search it from the drop down list the items in the dropdown list come from msql
the client can add more or delete items by clicking - or + whean the clint click send the client need to get a mail whit there a list of what theay have orderd and there unic order number wel so far we can do that but we wont to send another list to the company of order where the added products in the order ar sorted out based on the product id number
this is what we have so far http://clientconstru...sion.nl/valeri/
tyvm again voor anyone who read this ^^
Attached Files
bestel-form.png 37.78KB
0 downloads Hi, I have the project where i want to get the structure like tree. My table structu Section_Id Section_Parent Section_Name 1 0 America 2 0 China 3 1 New york 4 1 Washington 5 2 Buffalo How to retrieve the records.. I need a structure like this in a select button: America New york Buffalo Thanks, Hi I wanted to know how once I have selected and echoed the rows from mysql table how can I get it to number those rows that echo? etc 1. echo $variable 2. echo $variable 3. echo $variable 4. echo $variable 5. echo $variable Any help is appreciated Hi, I am new to php and need help. I am building a library system for an assignment. I want to provide a functionality that registers (adds) all transactions to defferent databases. I am stuck on how to add a selected row (selected by a checkbox) to the database and make sure that 2 users cannot update the same record at the same time. Thanks for your help. bellow is my code: Code: [Select] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=windows-1250"> <meta name="generator" content="PSPad editor, www.pspad.com"> <title>Web Works DD - Web Development & Software Solutions</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="css/style.css" /> </head> <body> <!--<div class="utilities"> <!-- UTILITIES MENU -- <a href="index.php" style=text-decoration:none;><img src="images/home.png" border="0" alt="Home Page"/> Home Page</a> <a href="sitemap.php" style=text-decoration:none;><img src="images/sitemap.png" border="0" alt="Sitemap"/> Sitemap</a> </div><!-- END UTILITIES --> <div id="right_bar"> <!-- right bar starts here --> </div> <!-- end of right bar --> <div id="top_bar"> <!-- top bar starts here --> <a href="index.php" style=text-ecoration:none; title="Web Works DD - Web Development & Software Solutions"><img src="images/mainLib.jpg" border=0 style=height:180;/> </a> <img src="images/topText.jpg" border=0 style=height:180;/> </div> <!-- end of top bar --> <div id="container"> <div id="top-logo"> <!--<a href="index.php" style=text-ecoration:none; title="Web Works DD - Web Development & Software Solutions"><img src="images/Main_logo.jpg" border=0 /> </a> --> </div> <ul class="dropdown dav"> <li><a href="index1.php">HOME</a></li> <li><a href="#" class="dir">VIEW RWSOURCES</a> <ul> <li><a href="books.php">BOOKS</a></li> <li><a href="dvds.php">DVDS</a></li> <li><a href="journals.php">JOURNALS</a></li> </ul> </li> <li><a href="staffLogin.php">STAFF ZONE</a></li> <li><a href="studentsLogin.php">STUDENT ZONE</a></li> </ul> <table> <!--This defines a new form --> <form action="" method="post"> <!--This creates the dropdown in html--> <select name="fields"> <option value="1">Please select...</option> <option value="isbnno">isbnno</option> <option value="title">title</option> <option value="description">description</option> <option value="author">author</option> </select> </td> </tr> <tr> <td> <input type="text" name="value" size="40"> </td> </tr> <tr> <td> <!-- Create a button --> <input type="submit" value="Select" name="select"> </td> </tr> </form> </table> <?php session_start(); include("secure/db_open.php"); /* $myusername=$_SESSION['myusername']; echo $myusername; $insert = $checkbox[$i]; $cops = $_POST['copies']; $userid ="SELECT id FROM students WHERE username = '$myusername'"; $uido = mysql_query($userid); $row = mysql_fetch_array($uido); echo $row['id']; */ // get variable after selecting something from the dropdown with name 'fields' $select = $_POST['select']; $valu = $_POST['value']; // if something has been chosen if (!empty($select)) { $fields = $_POST['fields']; //get the chosen value $allbooks="SELECT * FROM books WHERE {$fields} = '$valu'"; //select books that are available - driven by the user's input $copas="SELECT * FROM books WHERE {$fields} = '$valu' AND available_copies > 0"; $copy = mysql_query($copas); //count the number of rows resulting from the query $count=mysql_num_rows($copy); //$copse = mysql_fetch_array($copy); //select books that are not available $notavailable="SELECT * FROM books WHERE {$fields} = '$valu' AND available_copies = 0"; $shownotavailable=mysql_query($notavailable); $count1=mysql_num_rows($shownotavailable); //display a form echo "<table width='1100' border='0' cellspacing='1' cellpadding='0'>"; echo "<tr>"; echo "<td>" ; echo "<form name='form1' method='post' action=''>"; echo "<table width='1100' border='0' cellpadding='3' cellspacing='1' bgcolor='#CCCCCC'>"; echo "<tr>"; echo "<td align='center' colspan='9' bgcolor='#FFFFFF'>"; echo "<strong>Available to Loan </strong>" ; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td align='center' bgcolor='#FFFFFF'>Loan</td>"; echo "<td align='center' bgcolor='#FFFFFF'><strong>ISBN No.</strong></td>"; echo "<td align='center' bgcolor='#FFFFFF'><strong>Title</strong></td>"; echo "<td align='center' bgcolor='#FFFFFF'><strong>Description</strong></td>"; echo "<td align='center' bgcolor='#FFFFFF'><strong>Author</strong></td>"; echo "<td align='center' bgcolor='#FFFFFF'><strong>Loan Type</strong></td>"; echo "<td align='center' bgcolor='#FFFFFF'><strong>Location</strong></td>"; echo "<td align='center' bgcolor='#FFFFFF'><strong>Available Copies</strong></td>"; echo "<td align='center' bgcolor='#FFFFFF'><strong>Desired Num of Copies</strong></td>"; echo "</tr>"; while(($row = mysql_fetch_assoc($copy))) { echo "<tr>"; echo "<td align='center' bgcolor='#FFFFFF'><input name='checkbox[]' type='checkbox' id='checkbox[]' value=".$row['bookid']."></td>"; echo "<td>" .$row['isbnno']. "</td>"; echo "<td>" .$row['title']. "</td>"; echo "<td>" .$row['description']. "</td>"; echo "<td>" .$row['author']. "</td>"; echo "<td>" .$row['loan_type']. "</td>"; echo "<td>" .$row['location']. "</td>"; echo "<td>" .$row['available_copies']. "</td>"; echo "<td align='center' bgcolor='#FFFFFF'><input name='copies' type='text' id='copies' size='2'></td>"; echo "</tr>"; } echo "<tr>"; echo "<td colspan='9' align='center' bgcolor='#FFFFFF'><input name='loan' type='submit' id='loan' value='Loan Book'></td>"; echo "</tr>"; echo "</table>"; if (isset($_POST)) { session_start(); $myusername=$_SESSION['myusername']; $cops = $_POST['copies']; $userid ="SELECT id FROM students WHERE username = $myusername"; $uido = mysql_query($userid); $row1 = mysql_fetch_array($uido); $sid = $row1['id']; for ($i=0;$i<$count;$i++) { $insert = $checkbox[$i]; //echo "Welcome, ".$row['id']; $insertloaned="INSERT INTO studentloanedbooks(studentid, bookid, noofcopies) VALUES ($sid, $insert, $cops)"; $loaned = mysql_query($insertloaned); } } if($count1>0) { //display the books details //display a form echo "<br>"; echo "<br>"; echo "<table width='1100' border='0' cellspacing='1' cellpadding='0'>"; echo "<tr>"; echo "<td>" ; echo "<form name='form1' method='post' action=''>"; echo "<table width='1100' border='0' cellpadding='3' cellspacing='1' bgcolor='#CCCCCC'>"; echo "<tr>"; echo "<td align='center' colspan='9' bgcolor='#FFFFFF'>"; echo "<strong>Available to Loan </strong>" ; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td align='center' bgcolor='#FFFFFF'>Loan</td>"; echo "<td align='center' bgcolor='#FFFFFF'><strong>ISBN No.</strong></td>"; echo "<td align='center' bgcolor='#FFFFFF'><strong>Title</strong></td>"; echo "<td align='center' bgcolor='#FFFFFF'><strong>Description</strong></td>"; echo "<td align='center' bgcolor='#FFFFFF'><strong>Author</strong></td>"; echo "<td align='center' bgcolor='#FFFFFF'><strong>Loan Type</strong></td>"; echo "<td align='center' bgcolor='#FFFFFF'><strong>Location</strong></td>"; echo "<td align='center' bgcolor='#FFFFFF'><strong>Available Copies</strong></td>"; echo "<td align='center' bgcolor='#FFFFFF'><strong>Desired Num of Copies</strong></td>"; echo "</tr>"; while(($row = mysql_fetch_assoc($shownotavailable))) { echo "<tr>"; echo "<td align='center' bgcolor='#FFFFFF'><input name='checkbox[]' type='checkbox' id='checkbox[]' value='.$row[bookid]'></td>"; echo "<td>" .$row['isbnno']. "</td>"; echo "<td>" .$row['title']. "</td>"; echo "<td>" .$row['description']. "</td>"; echo "<td>" .$row['author']. "</td>"; echo "<td>" .$row['loan_type']. "</td>"; echo "<td>" .$row['location']. "</td>"; echo "<td>" .$row['available_copies']. "</td>"; echo "<td align='center' bgcolor='#FFFFFF'><input name='copies' type='text' id='copies' size='2'></td>"; echo "</tr>"; } echo "<tr>"; echo "<td colspan='9' align='center' bgcolor='#FFFFFF'><input name='reserve' type='submit' id='reserve' value='Reserve Book'></td>"; echo "</tr>"; echo "</table>"; } } // include("secure/db_close.php"); //include("secure/db_close.php"); ?> <!--if($cop>0){ --> <!-- this is my footer div --> <div id="footer"> Copyright © 2010 | <a href="privacy.php">Privacy Policy</a> | <a href="terms.php">Terms of Service</a> <img src="images/mini_logo1.png" align="right" style="margin-right:5" /> </div> <!-- End footer div --> </div> </div> </body> </html> MOD EDIT: [code] . . . [/code] BBCode tags added. Hello all, i have a table that displays data from mysql, now i want to update multiple rows from that table with checkboxes, the value will basically just switch from 'new' to 'done' so far i have this: Code: [Select] <tbody> <tr class="first"> </tr> <?php $ticketde=0; while ($ticketde < $numpscde) { $f1pscde=mysql_result($ticketresultde,$ticketde,"id"); $f2pscde=mysql_result($ticketresultde,$ticketde,"ticket"); $f4pscde=mysql_result($ticketresultde,$ticketde,"date"); $f5pscde=mysql_result($ticketresultde,$ticketde,"ip"); $f6pscde=mysql_result($ticketresultde,$ticketde,"done"); $setdone = ($f6pscde["done"] == 'n') ? "<a href=\"donepsc.php?id=".$f1pscde."\"><img src=\"ico_new.gif\" alt=\"new\" /></a>" : $f6pscde["done"]; if(isset($_POST['setdone'])){$checkbox = $_POST['checkbox']; $id = "('" . implode( "','", $checkbox ) . "');" ; $sql = "UPDATE ticket SET done='done' WHERE id='$f1pscde'"; $result = mysql_query($sql) or die(mysql_error()); } ?> <tr class="first"> <td class="tc"><font face="Arial, Helvetica, sans-serif"><?php echo $f1pscde; ?></font></td> <td class="tc"><font face="Arial, Helvetica, sans-serif"><?php echo $f2pscde; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f4pscde; ?></font></td> <td class="tc"><font face="Arial, Helvetica, sans-serif"><?php echo $f5pscde; ?></font></td> <td class="tc"><font face="Arial, Helvetica, sans-serif"><?php echo $setdone; ?></font></td> <td class="tc"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $f1pscde['id']; ?>"></td> </tr> <?php $ticketde++; } ?> </tbody> </table> <center><input type="submit" name="setdone" id="setdone" value="Set selected to done" class="button"/> - <input type="submit" name="exporttxt" id="exporttxt" value="Export selected to .txt" class="button"/> </center> </fieldset> </form> I found that checkbox code sample on some other site and tried to implement it, i don't really know where to go from here, as it's a total mess to me now, any help would be greatly appreciated. Have a look at this image Here is the part of the form code that makes them into arrays $sql="select * from products"; $res=mysql_query($sql); WHILE($fetch=mysql_fetch_assoc($res)){ echo "<td><input type=hidden name='desBox[]' id='desBox[]' value='".$fetch['prod_id']."'>".$fetch['prod_name']."</td> <td><input type=text id=quantBox[] maxlength=6 name=quantBox[]></td> <td><input type=text maxlength=6 id=teethBox[] name=teethBox[]></td>"; echo "</tr>";} Yesterday, I created a topic about how I could update records and I managed to achieve that successfully. Now I have another dilemma. When I have a specific record I want to update, I want to change a category ID of an product (e.g. change it from 1 to 2) but how do I go about doing this? Here is my code thus far: Code: [Select] <?php require_once ('./includes/config.inc.php'); require_once (MYSQL); $id=$_GET['prodID']; $results = mysqli_query($dbc, "SELECT * FROM product WHERE prodID=".$_GET['prodID'].""); $row = mysqli_fetch_assoc($results); ?> <form action="" method='POST'> Product ID: <input type="text" value="<?php echo $row['prodID'];?>" name="prodID" /> <br /> Product: <input type="text" value="<?php echo $row['product'] ;?>" name="product" /> <br /> Product Description: <input type="text" value="<?php echo $row['prod_descr'] ;?>" name="prod_descr" /> <br /> Category: <select name="category"> <option value="<?php echo $row['catID'];?>"></option> </select> Price: <input type="text" value="<?php echo $row['price'] ;?>" name="price" /> <br /> In Stock: <input type="text" value="<?php echo $row['stock'] ;?>" name="stock" /> <br /> <br /><input type="submit" value="save" name="save"> </form> <?php if(isset($_POST['save'])) { $id = $_POST['prodID']; $product = $_POST['product']; $descr = $_POST['prod_descr']; $price = $_POST['price']; $stock = $_POST['stock']; // Update data $update = mysqli_query($dbc, "UPDATE product SET product='$product', prod_descr='$descr', price='$price', stock='$stock' WHERE prodID=".$_GET['prodID'].""); header( 'Location: update_save.php' ) ; } ?> Hello, i am trying to get my form to list usernames ascending as an option, but the select field just returns blank. Here is my code: Code: [Select] /** * editUserForm - Displays the users database table in * a nicely formatted field table. */ function editUserForm(){ $q = "SELECT * " ."FROM ".TBL_USERS." ORDER BY username ASC"; $result = $database->query($q); while ($row = mysql_fetch_assoc($result)) { echo '<option value="'.$row["username"].'">'.$row["username"].'</option>'; } } Code: [Select] <form action="/" method="post"> <div class="column"> <p> <select name="user" id="user" placeholder="Select A User To Edit" class="{validate:{required:true}}"> <option>Select A User To Edit</option> <? editUserForm(); ?> </select> </p> <div class="action_bar"> <input type="submit" class="button blue" value="Submit Post" /> <a href="#modal" class="modal button">Cancel</a> </div> </form> All help is appreciated I have a simple database set up for story awards given out by different groups. Here are some of the fields I'm using: Author Title Year Summary Some of the rows are nearly identical with the same Author and Title, but sometimes a different year or or others have a Summary for the story where otherwise it would be empty for a different row. The problem I'm having is I want to fetch the summary of the story from all rows where the Author and Title are identical. Currently the code is fetching a random row with the same Author and Title, but won't show the Summary if that specific row doesn't have the summary filled in (and where other rows of nearly identical information would have the summary). Here's an example of nearly identical rows: 'Boring Title', 'Boring Author', '', '2012' 'Boring Title', 'Boring Author', 'Boring Summary', '2012' How would I go about fetching all rows with the identical Author and Title and then showing the Summary even if only one of those rows has information in the Summary field? Much obliged for any help. Here's the code I'm working with: Code: [Select] <?php mysql_connect(localhost,db_user,pw); @mysql_select_db(db_database) or die( "Unable to select database"); $quer="SELECT * FROM archives ORDER BY RAND() DESC LIMIT 1"; $re = mysql_query($quer); while ($ro = mysql_fetch_array($re)) { extract($ro); $please = ''; if (strlen($ro[summary]) == 0) { $please = "The summary is empty. Please help the Archives by <a href=\"edit.php?cmd=edit&author=$author&title=$title\">filling out the summary</a>."; } $select_author = mysql_query("SELECT DISTINCT author FROM archives WHERE `title` = '" . mysql_real_escape_string($title) . "' ") or die (mysql_error()); $aut = ""; while ($row2 = mysql_fetch_array($select_author)) { $aut .= "<a href=\"author.php?author={$row2[author]}\">$row2[author]</a> & "; } $aut = substr($aut,0,-3); echo '<div style="margin: 5px;"> '.$summary.''.$please.' <p style="float: right; width: 100%; margin-top: 10px; text-align: right;"><i> ~ <a href="info.php?author='.$author.'&title='.$title.'">'.$title.'</a> by <a href="author.php?author='.$author.'">'.$aut.'</a></i> </div>'; } ?> Hi Good day Can someone pls help me regarding with this matter. I have a page for inserting records. And I have a combobox that is fetched through the specific field in database. I also have a table of records, for each row i have an href edit which throws the values to its respective texbox and combobox. THE PROBLEM is that when i click the href edit, the value from a selected row was not displayed from the combobox Im trying to write some code for a raffle, when someone buys one ticket it works well but if someone buys ten tickets. i would like it to put each one on a new row, the last column is the ticket number which is got by another table called count and i want the new count in the last column of each row. In the actual script there is more than two columns but this is an example just to try to let you know what im trying to do. As you can see i want the ticket number to increment by one every time someone buys tickets. (the ticket number is in a simple table with just id and ticket number) EXAMPLE someone buys 2 tickes name | ticket number John | 1 john | 2 then someone buys three tickets jane | 3 jane | 4 jane | 5 This is what i have. (WORKING EXAMPLE of the code tha doesnt work.) as you can see the ticker number stays the same and not increment by one. <?php $num //is a number between 1 and 10 $tr //is the current count got from database (this needs to count up by one every entry) include 'includes/connect.php'; $num = "3"; // number of tickets someone buys. $count = "5"; // count of tickets already sold (so this is start count for this transaction). $id = "1"; // this is the line the counter is on to keep count updated for the amount of tickets sold. $name = 'john'; //example name for($i=0;$i< $num;$i++){ $count="$count+1"; // increments count by 1 $sql123 = "UPDATE count SET count=$count WHERE id='$id'"; //should update database to new count $sql = "INSERT INTO test (name, number) VALUES ('$name', '$count')"; if($result = mysqli_query($con, $sql)){ echo "<br>tickets bought and entered into database,<br>Thank you<br>"; } else { echo "Error: " . $sql . "<br>" . $con->error; } } ?> Not sure what im doing wrong? Thank you in advance Nook6 Hi - i need help with the fourth column named "jobnr" it has to be the highest number first and lowest at the bottum of the tabel. I tried different variation like "mysql_query("SELECT * FROM tabel ORDER BY jobnr DESC")" but with no success. I attached a picture og the working script output Code: [Select] <html> <head> <meta http-equiv="Content-type" content="text/html; charset=UTF-8"/> </head> <style type="text/css"> .myclass { font-size: 8pt; font-face: Verdana; } </style> <body> <?php // Define variables $host="host"; // Host name $username="user"; // Mysql username $password="password"; // Mysql password $db_name="database"; // Database name $tbl_name="tabel"; // Table name // Connect to server and select databse mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // saetter db udtraek til UTF-8 endcoding mysql_set_charset('utf8'); // henter db data fra tabllen: jobpositons $sql="SELECT * FROM $tbl_name"; $result=mysql_query($sql); // Define $color=1 $color="1"; echo '<table border=0" bordercolor="#f3f3f3" cellpadding="1" cellspacing="1">'; echo "<tr bgcolor='#00aeef'> <th>Jobtitel</th> <th>Sted</th> <th>Oprettet</th> <th>jobnr</th> </tr>"; // sortere sql db data og indsaetter i html tabel while($rows=mysql_fetch_array($result)) { // If $color==1 table row color = #ffffff if($color==1){ echo "<tr bgcolor='#ffffff'><td class='myclass'>".$rows['Jobtitel']."</td><td class='myclass'>".$rows['Sted']."</td><td class='myclass'>".$rows['oprettet']."</td><td class='myclass' align='right'>".$rows['jobnr']."</td> </tr>"; // Set $color==2, for switching to other color $color="2"; } // When $color not equal 1, use this table row color else { echo "<tr bgcolor='#f3f3f3'> <td class='myclass'>".$rows['Jobtitel']."</td><td class='myclass'>".$rows['Sted']."</td><td class='myclass'>".$rows['oprettet']."</td><td class='myclass' align='right'>".$rows['jobnr']."</td> </tr>"; // Set $color back to 1 $color="1"; } } echo '</table>'; mysql_close(); ?> </body> </html> what Im basically trying to do is just like a phpmyadmin function... you select rows you want to update with a checkbox and then it takes you to a page where the rows that are clicked are shown in forms so that you can view and edit info in them... and then have 1 submit button to update them all at once. I have 2 queries that I want to join together to make one row
I have this loop on a shorturl website i own that selects domains from my website and lists them in a dropdown list where users can select one domain to use as url shortener. The problem is that when a users selects and entry from the dropdown list this created only the [[[main_url]]] entry from the database table bellow can be used. When someone selectes "coolartistname.site.com the submit button cannot be pressed. in other words it's not adding the SELECTED attribute other than the [[[main_url]]] domain. Can anyone see on the code bellow why this would happen?
**Index.php** // get base urls $shortUrlDomains = getShortUrlDomains(); <?php foreach ($shortUrlDomains AS $k => $shortUrlDomain) { // active domains only if (($shortUrlDomain['premium_only'] !== '1') && ($shortUrlDomain['premium_only'] !== $Auth->id)) { continue; } echo '<option value="' . (int)$k . '"'; if (isset($_REQUEST['shortUrlDomain'])) { if ($k == (int)$_REQUEST['shortUrlDomain']) { echo 'SELECTED'; } } echo '>'; echo $shortUrlDomain['domain']; if ($disabled == true) { echo ' (' . safeOutputToScreen(t('unavailable', 'unavailable')) . ')'; } '</option>'; } echo '</optgroup>'; ?> FUNCTIONS.PHP function getShortUrlDomains() { // if we already have it cached if(defined('_SETTINGS_SHORT_URL_DOMAINS')) { return unserialize(_SETTINGS_SHORT_URL_DOMAINS); } // get connection $db = Database::getDatabase(true); // load from database $domains = $db->getRows("SELECT id, domain, premium_only, status FROM url_domain ORDER BY premium_only ASC, id ASC"); // organise and replace site url $rs = array(); foreach($domains AS $domain) { if($domain['domain'] == '[[[main_url]]]') { $domain['domain'] = _CONFIG_SITE_FULL_URL; } $rs[$domain{'id'}] = $domain; } **MYSQL DATABASE** url_domain (id, domain, premium_only, status, date_created, owner) VALUES (1, '[[[main_url]]]', 0, 'enabled', '2019-03-02 08:13:00', 1) (14, 'coolartistname.site.com', 6, 'enabled', '2020-04-18 19:21:59', 6);
This is my first real jump into PHP, I created a small script a few years ago but have not touched it since (or any other programming for that matter), so I'm not sure how to start this. I need a script that I can run once a day through cron and take the date from one table/filed and insert it into a different table/field, converting the human readable date to a Unix date. Table Name: Ads Field: endtime_value (human readable date) to Table Name: Node Field: auto_expire (Converted to Unix time) Both use a field named "nid" as the key field, so the fields should match each nid field from one table to the next. Following a tutorial I have been able to insert into a field certain data, but I don't know how to do it so the nid's match and how to convert the human readable date to Unix time. Thanks in advance!. Hi: I'm going crazy trying to do the following: I'm making a job registration process where the user registers on one php page to the website, must acknowlege and email receipt using an activate php page, then is directed to upload their C.V. (resume) based on the email address they enter in the active page output. I then run an upload page to store the resume in teh MySQL db based on the users email address in the same record. If I isolate the process of the user registering to the db, it works perfectly. If I isolate the file upload process into the db, it works perfect. I simply cannot upload teh file to the existing record based on teh email form field matching the user_email field in the db. With the processes together, teh user is activated, but teh file is not uploaded. Maybe I've simply been at this too long today, but am compeled to get through it by end day. If anyone can help sugest a better way or help me fix this, I will soo greatly appreciate it. My code is as follows for the 2 pages. ---------activate.php------- <?php session_start(); include ('reg_dbc.php'); if (!isset($_GET['usr']) && !isset($_GET['code']) ) { $msg = "ERROR: The code does not match.."; exit(); } $rsCode = mysql_query("SELECT activation_code from subscribers where user_email='$_GET[usr]'") or die(mysql_error()); list($acode) = mysql_fetch_array($rsCode); if ($_GET['code'] == $acode) { mysql_query("update subscribers set user_activated=1 where user_email='$_GET[usr]'") or die(mysql_error()); echo "<h3><center>Thank You! This is step 2 of 3. </h3>Your email is confirmed. Please upload your C.V. now to complete step 3.</center>"; } else { echo "ERROR: Incorrect activation code... not valid"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Job application activation</title> </head> <body> <center> <br/><br/><br/> <p align="center"> <form name="form1" method="post" action="upload.php" style="padding:5px;"> <p>Re-enter you Email : <input name="email" type="text" id="email"/></p></form> <form enctype="multipart/form-data" action="upload.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="4000000"> Upload your C.V.: <input name="userfile" type="file" id="userfile"> <input name="upload" type="submit" id="upload" value="Upload your C.V."/></form> </p> </center> </body> </html> --------upload.php---------- <?php session_start(); if (!isset($_GET['usr']) && !isset($_GET['code']) ) { $msg = "ERROR: The code does not match.."; exit(); } if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $email = $_POST['email']['user_email']; $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp); if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } include 'reg_dbc.php'; $query = "UPDATE subscribers WHERE $email = user_email (name, size, type, content ) ". "VALUES ('$fileName', '$fileSize', '$fileType', '$content')"; mysql_query($query) or die('Error, query failed'); mysql_close($dbname); } ?> <center> <br/> <br/> <br/> <br/> Thank you for uploading your <?php echo "$fileName"; ?> file, completing your registration, and providing us your C.V. for this position. <br/> <br/> <br/> We will contact you if your canditature qualifies. </center> Code: [Select] $new_array2=array_diff($my_array,$itemIds); $updatedb = mysql_query("UPDATE content_type_ads SET field_expire_value = '666' WHERE $new_array2 = field_item_id_value"); "$new_array2" has only 12 digit numbers for each item in the array, and I want to match them to the "field_item_id_value" field in the table, updating the "field_expire_value" field for the record where they match. I know I am close because the UPDATE code works before I add the WHERE statement (it of course adds '666' to EVERY field, but for a noobie it's a start!). (Another quite newbie...) I have already an online booking form. The Form works fine now and I would like to add on one more issue, but the code ignores what I want to check. I have 4 fields: arrival, departure, no. of persons and comments to check. Scenario 1: All field mentioned above are emtpty: Workes fine and message appears: "You have not provided any booking details". Scenario 2: If arrival (date_start) and departure (date_end) is entered, there should be at least an entry either in the field "comment", or in the field "pax". If not, there should be a message: "You have not provided sufficient booking details". INSTEAD: The booking request is sent, which should not be the case. The code is currently: # all fields empty : arrival, departure, pax and comments - error if(empty($data_start) && empty($data_end) && empty($pax)&& empty($comment)){ exit("You have not specified any booking details to submit to us. <br>Please use your browser to go back to the form. <br>If you experience problems with this Form, please e-mail us"); exit; } #If arrival and departure date is entered, there should be at least an entry either in the field "comment", or in the field "pax". if(!isset($data_start) && !isset($data_end) && empty($pax) && empty($comment)){ exit("You have not provided sufficient booking details. <br>Please use your browser to go back to the form. <br>If you experience problems with this Form, please e-mail us"); exit; } The form can be tested at http://www.phuket-beachvillas.com/contact-own/contact-it.php Can someone please check and tell me what's wrong with the code ? Thanks to anyone for any hint. |