Jump to content

Barand

Moderators
  • Posts

    24,602
  • Joined

  • Last visited

  • Days Won

    830

Everything posted by Barand

  1. You wouldn't store any of those items in a database, you should be able to derive them from the existing post data when required.
  2. yes, and bookings
  3. What does your data table/s look like?
  4. First recommendation is for you to use CSS styles EG <style type="text/css"> table { border-collapse: collapse; } td.free { text-align: center; background-color: white; } td.booked { background-color: #FF8080; } </style> When you move on to a new month, query your db for appointments in that month and store in an array, keyed by day number. Then it is easy to look up each day as you out put it in the table and give it the appropriate class name to style it. Make each cell with a date clickable so you can display the form for that day (jquery is the easiest method).
  5. 1. You need to assign the results of a SELECT query to a result object 2. mysqli_query requires the db connection object as the first argument 3. mysqli_fetch_xxxxx requires the result object as the argument. All you need is a single INSERT ... SELECT query. INSERT INTO admin (username, password, age, phonenumber, nationality) SELECT username, password, age, phonenumber, nationality FROM login WHERE username='$searchq'
  6. That seems to be same problem I pointed out to you last October http://forums.phpfreaks.com/topic/291987-if-then-question/?do=findComment&comment=1494981 You need the reading at the beginning of the period and the reading at the end then subtract one from the other. If it is negative, add 10M.
  7. You need look no further than the PHP manual for mail() function
  8. Sounds like you would have something like the model attached below. This assumes a particular option applies to a single submodel As for your selection then maybe have a series of linked dropdowns. A dropdown menu of series A dropdown of those models belonging to the series selected in menu 1 A menu of those submodels belong to the selected model A menu of the options for the selected submodel A menu of products belonging to the selected option
  9. I don't know the output you want but this should get you on your way $xml = new SimpleXMLElement($_xml_string); foreach ($xml->xpath("//Outcome") as $out) { $oid = $out['id']; foreach ($out->Bookmaker as $bk) { $bkname = $bk['name']; $bklu = $bk['lastUpdate']; foreach ($bk->Odds as $odd) { $outcomes[] = array ( 'Outcome' => (string)$oid, 'Bookmaker' => (string)$bkname, 'Updated' => (string)$bklu, 'Bet' => (string)$odd['bet'], 'SP' => (string)$odd['startPrice'], 'CP' => (string)$odd['currentPrice'], 'Decimal' => convertPrice ((string)$odd['currentPrice']) ); } } } function convertPrice($price) { list ($a,$b) = explode('/', $price); return $a/($a+$b); } function priceSort($a, $b) { return strcmp($a['Decimal'], $b['Decimal']) ; } usort($outcomes, 'priceSort'); echo '<pre>',print_r($outcomes, true),'</pre>';
  10. I can see the problem but am unable to help without confessing to being a pimp. Sorry.
  11. If you had posted the original xml then I would look at it. I am not prepared to spend all evening editing print_r() output into something that can be processed.
  12. A table subquery needs to be given a table alias SELECT * FROM ( SELECT ... ) as top9 ORDER BY RAND()
  13. Make the $_SERVER["HTTP_X_MXIT_USERID_R"] value part of a unique key in your table then it becomes impossible to write a duplicate. EG> UNIQUE KEY (poll_id, user_id)
  14. Yes, you are, but only if $_GET['id'] is set
  15. It also works if you change them individually $xml = new SimpleXMLElement($_xml_string); $xml->EmbeddedDoc[0] = '##FILE##' ; $xml->EmbeddedDoc[1] = '##FILE##' ; $newxml = $xml->asXML(); echo '<pre>' . htmlentities($newxml) . '<pre>';
  16. 1. Store selected language in a session variable and use the "selected" attribute to select the stored language 2. Use <optgroup> to group the subcats into categories session_start(); if (isset($_GET['lang'])) { $_SESSION['lang'] = $_GET['lang']; // store newly selected lang } if (!isset($_SESSION['lang'])) { $_SESSION['lang'] = 'Esp'; // set default if not yet set } // LANGUAGE OPTIONS $langs = array( "Esp" => "Espanyol", "Eng" => "English", "Cat" => "Catalan", "Bas" => "Euskal", "Gal" => "Galego", ); $langOpts = ''; foreach ($langs as $k => $l) { $sel = ($k == $_SESSION['lang']) ? 'selected="selected"' : ''; $langOpts .= "<option value='$k' $sel> $l</option>\n"; } // CATEGORY OPTIONS $cats = array ( "A" => array ("b", "c"), "D" => array ("e", "f") ); $catOpts = ''; foreach ($cats as $c => $subs) { $catOpts .= "<optgroup label='$c'>\n"; foreach ($subs as $sc) { $catOpts .= "<option value='$sc'> $sc</option>\n"; #$catOpts .= "<option value='$sc'> $sc</option>\n"; } $catOpts .= "</optgroup>\n"; } ?> <html> <head> <style type="text/css"> option.subcat { padding-left: 25px; } </style> </head> </html> <form> Language <select name="lang" onchange="javascript:change_langs(this.form)"> <?= $langOpts ?> </select> <br> Category <select name="category"> <option value=''>Select ...</option> <?= $catOpts ?> </select> <input type="submit" name="btnSub" value="Submit"> </form>
  17. start values again mysql> SELECT * FROM city; +----+------+------+------------+ | id | xpos | ypos | cityname | +----+------+------+------------+ | 1 | 40 | 60 | Manchester | | 2 | 80 | 60 | Leeds | | 3 | 90 | 160 | Leicester | +----+------+------+------------+ Now this code, where id=2 and ypos left blank $db = new mysqli(HOST,USERNAME,PASSWORD,DATABASE); if (isset($_POST['id'])) { $id = $_POST['id']; // 2 $ypos = empty($_POST['ypos']) ? null : $_POST['ypos']; // empty $sql = "UPDATE city SET ypos = ? WHERE id = ?"; $stmt = $db->prepare($sql); $stmt->bind_param('ii', $ypos, $id); $stmt->execute(); } Tables values after running code mysql> SELECT * FROM city; +----+------+------+------------+ | id | xpos | ypos | cityname | +----+------+------+------------+ | 1 | 40 | 60 | Manchester | | 2 | 80 | NULL | Leeds | | 3 | 90 | 160 | Leicester | +----+------+------+------------+
  18. Doh! So it is. As it works, what was your problem then?
  19. Example: mysql> SELECT * FROM city; +----+------+------+------------+ | id | xpos | ypos | cityname | +----+------+------+------------+ | 1 | 40 | 60 | Manchester | | 2 | 80 | 60 | Leeds | | 3 | 90 | 160 | Leicester | +----+------+------+------------+ mysql> UPDATE city SET cityname=NULL WHERE id = 2; mysql> SELECT * FROM city; +----+------+------+------------+ | id | xpos | ypos | cityname | +----+------+------+------------+ | 1 | 40 | 60 | Manchester | | 2 | 80 | 60 | NULL | | 3 | 90 | 160 | Leicester | +----+------+------+------------+
  20. or <?php $str = "/index.php?g1=111&g2=222&g3=333"; $bits = parse_url($str); parse_str($bits['query'], $vals); echo '<pre>',print_r($vals, true),'</pre>'; ?> gives Array ( [g1] => 111 [g2] => 222 [g3] => 333 )
  21. I do not know if it works with PDO but prepared statements with MySQLi will write NULL to a field if the bound parameter has a null value
  22. If you are going to normalize as ginerjm recommended then do it properly and not have multiple values in a single field. "AuthorA2000a" is 3 separate fields viz. | Name | Year | Sequence | You would store publications in separate table from the Author table and store the authorID as a foreign key author +----------+-------------------+ | authorID | name | +----------+-------------------+ | 1 | AuthorA | | 2 | AuthorB | +----------+-------------------+ | | +-------------------------------------+ | publication | +---------+-------+----------+------------+ | pubID | year | authorID | pubname | +---------+-------+----------+------------+ | 1 | 2000 | 1 | pub 1 | | 2 | 2000 | 1 | pub 2 | | 3 | 2001 | 1 | pub 3 | | 4 | 2000 | 2 | pub 4 | | 5 | 2001 | 2 | pub 5 | | 6 | 2002 | 2 | pub 6 | | 7 | 2002 | 2 | pub 7 | +---------+-------+----------+------------+
  23. ginerjm's code relies on your having an array of filenames ($files_ar), which he didn't show. This could be hard-coded as in my example below or you could read the list into an array from a text file. <?php $files_ar = array ( 1 => 'Lesson1.html', 'Lesson2.html', 'Lesson3.html', 'Lesson4.html', 'Lesson5.html', ); if (isset($_GET['file']) && $_GET['file']<>'') { $file = strtolower($_GET['file']); if (array_key_exists($file,$files_ar)) $include_name = $files_ar[$file]; else die("Invalid url value"); include('header.php'); include($include_name); include('footer.php'); exit(); } else die("Missing url value"); exit(); ?> You would then call the page with thissite.com/index.php?file=1 etc
  24. Use "=" instead of "LIKE" WHERE registration = '$searchq'
  25. What about the firefox array and the others that do not work? If you have a 30 element array then array_slice($array, 5, -24) leaves a single element $a = range(1,30); $array = array_slice($a, 5, -24, 1); echo '<pre>',print_r($array, true),'</pre>'; /* results ************** Array ( [5] => 6 ) ****************************/ So if that 1 element doesn't contain what you are looking for then it won't work. Why use array_slice() here anyway?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.