biggieuk
Members-
Posts
159 -
Joined
-
Last visited
Everything posted by biggieuk
-
Hi, Im having a little problem with my dropdown. It is populated dynamically from images inside a folder. I have a 'preview button' next to the dropdown which i would like (when clicked) to popup a window displaying the image in the dropdown. I tried making the preview button have code along the lines of: <img src="../images/uploaded/+document.getElementById.[imgdropdown].value" /> however this didnt work. Thanks for any help with this!
-
At the moment its producing this: instead of: Thanks.
-
Thanks gevans, That seemed to work for the middle columns, however previously the 'selection' column would span over a number of extra columns as the values stored in there are seperated by commas. e.g. (12,34,65,87,89) - This would span over 5 columns. Is there a way to replace these commas with a new row? thanks again
-
Hi all, I am using the following script to export a list of bookings from a mysql database: <?php require_once('../Connections/hwbltaconf.php'); header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=SessionList.csv"); header("Pragma: no-cache"); header("Expires: 0"); mysql_select_db($database_hwbltaconf, $hwbltaconf); $query = "SELECT title, ampm, capacity, placesbooked FROM sessions"; $exp = mysql_query($query); $count = mysql_num_fields($exp); for ($i = 0; $i < $count; $i++) { $header .= mysql_field_name($exp, $i).","; } while($row = mysql_fetch_row($exp)) { $line = ''; foreach($row as $value) { if ((!isset($value)) OR ($value == "")) { $value = "\t"; } else { $value = str_replace('"', '""', $value); $value = '"' . $value . '"' . ","; } $line .= $value; } $data .= trim($line)."\n"; } $data = str_replace("\r", "", $data); if ($data == "") { $data = "\n(0) Records Found!\n"; } print "$header\n$data"; exit; ?> this works fine when all fields in the middle are present, however if a 'year' value is missing the next columns value is put into this instead of leaving it blank. The output looks like this (when there is a value missing): username | email | year | course | selection ---------------------------------------------------------------------------- Test User test@tickle.com Course 1 99 Any idea how i can have the specific column blank if the db value is blank? thanks.
-
thanks for the reply, The userid is in a different table to where the selections are stored. Is there a more complicated query that can read the userid, select the selections and read them from the 'selections' table?
-
If it helps, my tables are laid out similar to this: user table userid username selections 1 Dan 2,5,6 2 Pete 1,3,5 selections table id title 1 Option one 2 Option two 3 Option three the dropdown value is the 'userid'. I want to be able to select a user and have the 'title' of each session display. thanks again
-
Hi all, Ill try explain my problem as much as i can, let me know if you need anything clearing up. I have a dropdown box which is populated from 'users' table in mysql db: <select name="users" id="users" onchange="window.location.href='<?=$HTTP_SERVER_VARS['PHP_SELF']; ?>?userid='+this.options[this.selectedIndex].value+'&id=<?=$row_selectSessions['selections'];?> ';"> <? if(mysql_num_rows($userlist)) { while($row_userlist = mysql_fetch_assoc($userlist)) { ?> <option value="<?=$row_userlist['userid'];?>" <? if ($_GET['userid'] == $row_userlist['userid'] ){ echo "Selected"; } ?> ><?=$row_userlist['username'];?> - <?=$row_userlist['email'];?></option> <? } } else { echo "<option>Nothing Found</option>"; } ?> </select> When a user is selected the onChange property refreshes the current page and appends a '?userid=[value from dropdown item]?id=[users Selections, stored in the users database e.g 12,34,56,78 ] These selections are also ids of items in the 'selections' table. I have a php procedure in the head of my page which GETs the 'userid' from the querystring and sets the dropdown to the same value before the refresh. The procedure also GETs the 'id' value and uses 'explode' to split these up and individually retreive the Titles from the 'selections' table. Ive managed to get this working ok, however as the page is being refreshed the 'id' in the URL is the previously selected and so the previous Selection Titles are returned. Anybody know how i can get around this, hope ive not made it sound too complicated. Thanks
-
Hi all, I have a little problem which im struggling to get my head around. In my MYSQL session table i have a field called 'practical' which contains either a 1 or 0, based on if the session is a practical or not. My PHP form contains two repeating tables, one containing morning sessions and one with afternoon sessions followed by a checkbox. I have appended these values in a hidden field using: <input type="hidden" name="practicalAM1[]" id="<?=$sessionPM1['groupid']; ?>" value="<?=$row_sessionAM1['practical']; ?>"/> These checkboxes are named: checkedAM1[] & checkedPM1[]. I now need to validate this form so that only one Practical session is checked from the whole of checkedAM1 and checkedPM1. I tried the following test but do not receive a popup when a practical session is selected: function ChkPractical(oN,aM){ var myObj = document.forms['form1'].elements[oN]; // cycle through radio buttons and test if hidden value is 1 var i = 0; for(var j=0;j<myObj.length;j++){ if(myObj[j].value ==1){ i++; } } if (i==1){ myObj[0].focus(); alert(aM); return false; } else { return true; } } its use: ChkPractical('practicalAM1[]', 'Please Select Only 1 Practical Session') If anybody knows a better way or where im going wrong then your help is very much appreciated! thanks.
-
Obviously ive tried Google.. However, ive not managed to find anything that downloads backup to the users computer. Here is my current code: $host = $hostname_hwbltaconf; $dbuser = $username_hwbltaconf; $dbpword = $password_hwbltaconf; $dbname = $database_hwbltaconf; $backupFile = date("Y-m-d") . '.gz'; # Use system functions: MySQLdump & GZIP to generate compressed backup file $command = "mysqldump -h$host -u$dbuser -p$dbpword $dbname | gzip> $backupFile"; system($command); # Start the download process $len = filesize($backupFile); header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Type: application/gzip"); header("Content-Disposition: attachment; filename=$filename;"); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".$len); @readfile($backupFile); # Delete the temporary backup file from server unlink($backupFile); This is held in a seperate php page and when the 'backup' link is clicked it only shows that i can download backupdb.php (the file where the code is stored). Any ideas how i can download the .gz file instead? Thanks!
-
Hi all, I have a database of 8 tables in mysql and wanted the user to be able to export a backup of the database to their computer. I also need the user to be able to export a partially blank database so that all but a couple of the tables contain no data but retain the structure. Is this possible using PHP? thanks for help or guidance with this! Dan.
-
Dont think i explained myself properly so here is images of what im trying to achieve: Excel output looks like this: I need it to split the values into cells like this: thanks!
-
Hi again, Just want to re-open this thread and ask another question.. In my database the final column stores values either like 21,11,40 or a single number. Is it possible to output the values stored with commas into separate columns. e.g... |Selections| | | -------------------------- | 21 | 11 | 40 | thanks.
-
Thanks for your help, I changed the /t to , and its exporting as i wanted now.
-
Hi all, I am using the following code to export a list of user data from my mysql database: <?php require_once('../Connections/conn.php'); header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=users.csv"); header("Pragma: no-cache"); header("Expires: 0"); mysql_select_db($database_conf, $userconf); $select = "SELECT * FROM users"; $export = mysql_query($select); $count = mysql_num_fields($export); for ($i = 0; $i < $count; $i++) { $header .= mysql_field_name($export, $i)."\t"; } while($row = mysql_fetch_row($export)) { $line = ''; foreach($row as $value) { if ((!isset($value)) OR ($value == "")) { $value = "\t"; } else { $value = str_replace('"', '""', $value); $value = '"' . $value . '"' . "\t"; } $line .= $value; } $data .= trim($line)."\n"; } $data = str_replace("\r", "", $data); if ($data == "") { $data = "\n(0) Records Found!\n"; } print "$header\n$data"; exit; ?> This exports to a file okay but it is being displayed in a single line, for instance the column headers are showing as: useridusernameemailorganisationselections Is it possible for the user to export from mysql and have everything sorted into columns? P.s. im using Excel 2008 if that makes a difference? thanks very much.
-
Thanks to the both of you. You were right, Server side is a lot better method. Thanks!
-
thanks for your reply, however i cant seem to get this working. Would using, if(selObj.options.text=='<?php echo $id; ?>') look for the dropdown text value to equal the id ? Whereas i am looking to set the dropdown to the same VALUE as 'id'. I tried changing .text to .value but the dropdown doesn't change on page reload? thanks again for your help.
-
Hi, I have a web page with a dynamically populated dropdown box and a textarea. Currently when a value is selected the page reloads and the database data corresponding to the value of the dropdown is returned to the textarea, however the dropdown does not keep to the same value. On page reload i have appended a ?id=<id here>. The javascript is: <script language="javascript" type="text/javascript"> function load() { document.getElementById('lstGroup').selectedValue = <? echo $id; ?>; } </script> It works if i change selectedValue to selectedIndex but i want to set the dropdown box to the value in the $id variable. help with this would be very much appreciated. thanks.
-
Hi, Not too sure if this is the correct forum for this as im not too sure as to a specific solution. I am using the YouTube API to read the authorized users videos into my application. the function to display this is: function echoVideoList($feed, $authenticated = false) { $table = '<table id="videoResultList" class="videoList"><tbody>'; $results = 0; foreach ($feed as $entry) { $videoId = $entry->getVideoId(); $thumbnailUrl = 'notfound.jpg'; if (count($entry->mediaGroup->thumbnail) > 0) { $thumbnailUrl = $entry->mediaGroup->thumbnail[0]->url; } $videoTitle = $entry->mediaGroup->title; $videoDescription = $entry->mediaGroup->description; $videoCategoryArray = $entry->mediaGroup->category; $videoTags = $entry->mediaGroup->keywords; $table .= '<tr id="'. $videoId .'">'. '<td width="100%"><img onclick="ytVideoApp.presentVideo(\''. $videoId. '\')" src="'. $thumbnailUrl. '" /></td>'. '<td>'. '<a href="#" onclick="ytVideoApp.presentVideo(\''. $videoId. '\')">'. stripslashes($videoTitle) .'</a>'; if ($authenticated) { $table .= '<p class="edit"><a onclick="ytVideoApp.presentMetaDataEditForm(\''. addslashes($videoTitle) .'\', \''. addslashes($videoDescription) .'\', \''. $videoCategoryArray . '\', \''. addslashes($videoTags) .'\', \'' . $videoId .'\');" href="#">edit video data</a> | <a href="#" onclick="ytVideoApp.confirmDeletion(\''. $videoId .'\');">delete this video</a></p><br clear="all">'; } $table .= '</td></tr>'; $results++; } This is reading from youtube and displaying the users videos in a list with the video title and 'Edit|Delete' text. I want to be able to display a grid of thumbnails instead of this. The thumbnails would then be displayed as a 3x3 table. How can i echo the thumbnails into a grid like this? any help with this is appreciated.
-
thanks very much, both variations work great!
-
thanks for this, seems to be working apart from the formatting. Im receiving: Morning: Sport<br />Maths<br />Afternoon:<br>Radiology<br />Physiotherapy<br /> wheres it should be more like: Morning: Sport Maths Afternoon: Radiology Physiotherapy How could i change the code to reflect this? thanks again!
-
sorry, im receiving a parse error on line 50, which is: foreach($_SESSION['am'] as $key=>$value) im guessing ive not put the foreach loop into the $msg variable correctly?
-
Hi all, I am trying to send an e-mail with the following message body: <POSTed value> ------------------------------ Details: Name: email: Morning Sessions: <array[0]> = value <array[1]> = value ...... the code i am using is: $to = $email; $subj = "PESDC Booking Confirmation"; $msg = $_POST['dbemail']; $msg.= "\n --------------------------------------------- Name: $name E-mail: $email Morning: ". foreach($_SESSION['am'] as $key=>$value) { echo $value. '<br />'; } ." Afternoon: ". foreach($_SESSION['pm'] as $key=>$value2) { echo $value2. '<br />'; } $header = "From: confirmation"; $mailsend = mail($to, $subj, $msg, $header); SESSION['am'] and SESSION['pm'] are separate arrays stored in a session variable. What is the correct method of doing this? thanks
-
[SOLVED] Query multiple tables for repeating table
biggieuk replied to biggieuk's topic in MySQL Help
brilliant, thanks! -
[SOLVED] Query multiple tables for repeating table
biggieuk replied to biggieuk's topic in MySQL Help
thanks for this however i don't think i explained what i wanted very clearly. This returns the rows of data that have a resource applied to them only. I need all of the rows from session to be displayed and if a resource has been added to that session then the path is displayed, otherwise the path field is left blank. I have tried: SELECT s.group, s.mentor, s.room, r.path FROM sessions s JOIN resource r This returns the whole of the sessions table and the same path for all of the sessions which shouldn't be the case. -
managed to do this by looking into ajax.