-
Posts
1,216 -
Joined
-
Last visited
Everything posted by WebStyles
-
Putting dynamic menu results back into database
WebStyles replied to davidcriniti's topic in PHP Coding Help
It seems the value of ID is not reaching the next page. Are you sure your <select> box is inside the <form> ? -
checkbox with multiple values processing into MySql
WebStyles replied to rilana's topic in PHP Coding Help
when you do this: <input type="checkbox" name="beruf[]" value="4,9,10,11"/> because you included [] after the input name, it means the result will be an array, so you can have several inputs with the same name. you grab the value with the array index: $beruf = strip_tags($_POST['beruf'][0]); if you only have 1 input, remove the [] so it will looklike this: <input type="checkbox" name="beruf" value="4,9,10,11"/> and then this should work: $beruf = strip_tags($_POST['beruf']); -
what I normally do in these cases is store arrays in a separate file. I don't store the entire dropdown html for the simple reason that sometimes I want it to have different names, and sometimes I want it to be static, others I want it to be auto-selected with a value, so I do something like this: array.txt $combo = array( "newton"=>"Isaac Newton", "einstein"=>"Albert Einstein", "davinci"=>"Leonardo DaVinci" ); and just use: include_once('array.txt'); echo '<select name="whatever" size="1">'; foreach($combo as $value => $name){ echo '<option value="'.$value.'">'.$name.'</option>'; } echo '</select>'; this way I can also do this: include_once('array.txt'); echo '<select name="whatever" size="1">'; foreach($combo as $value => $name){ echo '<option value="'.$value.'"'; if($value == $defaultValue) echo ' selected'; echo '>'.$name.'</option>'; } echo '</select>'; and also have the option do add a blank value when needed: include_once('array.txt'); echo '<select name="whatever" size="1">'; echo '<option value=""></option>'; foreach($combo as $value => $name){ echo '<option value="'.$value.'"'; if($value == $defaultValue) echo ' selected'; echo '>'.$name.'</option>'; } echo '</select>'; Its just my personal preference for small dropdowns that hardly ever need updating, hope this helps
-
Gotta agree with the other guys, what you're doing sounds a bit weird... from what I understand, $include_a is always the first element retrieved from the xml, and $include_b is always the second, and $include_c is always the third? And then you manually list the wanted/unwanted id's and create a variable for each, in which you assign true of false? I don't see much point to this. Too much stuff to do manually. What would happen if you xml file retuned 20 different values? would you manually create a variable d, e, f, g... etc... for each? I would load the entire XML into the array, and have a second array with only the numbers I want to process.... Like you said, in_array() can then solve the rest... so try something like this: (assuming you have an array called $xmlFile with the loaded data) $validIDS = array('24','5'); foreach($xmlFile as $k => $item){ if(in_array($item['id'],$validIDS){ //.. Calculate }else{ // you can remove the unwanted ones from the array if necessary unset($item[$k]); } } this way, all you need to do is update the ids in $validIDS. it's still not a great way to do it, but I don't really understand what your selection logic is, how do you decide if you want ID number 24 or not? hope this helps
-
checkbox with multiple values processing into MySql
WebStyles replied to rilana's topic in PHP Coding Help
remove the single quotes <input type="checkbox" name="beruf[]" value="4,9,10,11"/> value grabbed in php will be: 4,9,10,11 now you can use explode() to separate them if necessary. -
you're welcome. google it though, like jcbones said, so you can get an explanation on how it works.
-
grab $_GET['ref'] and keep it in a $_SESSION variable, then if they register, update their points.
-
list($width, $height, $type, $attr) = getimagesize("image_name.jpg"); took me 2 seconds to find that on google.
-
instead of $row=mysql_fetch_array($result); you need to loop though all the results with while($row=mysql_fetch_array($result)){ //... } otherwise you're only using 1 value from the database.
-
in your update script, $id is not set.
-
$model=str_replace(" ","",trim($_GET["model"]));
-
Help displaying a particular page on first login
WebStyles replied to lukep11a's topic in PHP Coding Help
something like: "select * from `selections` where `username` = '$username' limit 1" hope this helps -
echo $row['note_end_date'] and post the result here.
-
writing info from one table to another within the same database
WebStyles replied to leijae's topic in PHP Coding Help
are you sure $_REQUEST['user'] exists and has a valid value? echo it just to make sure. -
writing info from one table to another within the same database
WebStyles replied to leijae's topic in PHP Coding Help
try changing this: $id = mysql_query("SELECT id FROM users WHERE username = ' " .$_REQUEST['user']." ' "); for something like this: $q = mysql_query("SELECT id FROM users WHERE username = ' " .$_REQUEST['user']." ' "); $r = mysql_fetch_assoc($q); $id = $r['id']; -
do you have a server with php enabled? do you have a mysql database? do you know how to create a database and a table with id/user/pass fields? do you know how to connect to a database? do you have any code at all? maybe an html form for the login? anything?
-
get info from URL and set as a javascript variable
WebStyles replied to jarvis's topic in PHP Coding Help
hmm....so you have a list of videos you're trying to play/display without refreshing the page? why not just call a js function and pass the url to it? -
as I said before, the title tag <title> must be inside your <head> tags. you have one <title> inside header.php (that is also inside <head> tags, so this is correct) then you have a <title> tag lost at the top of your index.php. remove <title> line from index.php.
-
what is inside header.php ?
-
off the top of my head, maybe something like this: (untested) <?php while ($row = mysql_fetch_array($sql)){ $bgColors = strtotime($row['note_end_date']) > time() ? '#FF99FF' : '#CCCCCC'); // Print out the contents of each row into a table echo "<tr bgcolor=\"{$bgColors[$row['sex']]}\">\n"; echo "</td><td>"; echo $row_counter++; echo "</td>"; echo "<td>{$row['firstname']}</td>\n"; echo "<td>{$row['lastname']}</td>\n"; echo "<td>{$row['sex']}</td>\n"; echo "<td>{$row['notes']}</td>\n"; echo "<td>{$row['note_end_date']}</td>\n"; echo "</tr>\n"; } echo "</table>"; ?>
-
get info from URL and set as a javascript variable
WebStyles replied to jarvis's topic in PHP Coding Help
<div id="ytvideo"></div> is just an empty div with a name. it won't have any content unless you put some into it. if you have a php variable with the content you wish to pass on to js, just echo it. this is just one way of doing it, and unless you set the div to hidden, the url will display on your page. <div id="ytvideo"><?php echo $url;?></div> alternatively you can also use hidden form elements. And I'm quite sure Andy-H's example should work fine too. -
get info from URL and set as a javascript variable
WebStyles replied to jarvis's topic in PHP Coding Help
var theURL = document.getElementById("ytvideo").innerHTML; will only work if there's actually some text inside your <div> if you do this: <div id="ytvideo">www.facebook.com</div> then your javascript var theURL should grab the value www.facebook.com -
I still don't quite understand what you're getting at, since you've posted so little code. html <title> tags must be withing your <head>...</head> section. If you're not including the <head> section on some pages, then it probably won't work.
-
I just took a quick glance, but it seems your "pagination" style is only applied if $currentpage is greater than 1 if ($currentpage > 1) { echo "<div class='pagination'><a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a>"; that will make it not show when you're on the fist page. you should have both the div tags (start and end) outside of the conditions, so they're always applied.
-
I suppose if you can CURL the page into a php variable, you can check the length/contents and compare with previous version to decide if there have been updates or not. Sounds illegal though. If they have a paid service providing exactly what you want, chances are they'll detect what you're doing and block your IP, or even begin legal action against you for trying to explore their business.