
Drummin
Members-
Posts
1,004 -
Joined
-
Last visited
Everything posted by Drummin
-
Or with keeping user ID's and Pet ID's in the mix. <?php $data = array(); $data['user'] = array(1,2); $data['name'] = array('Debbie','Sally'); $data['pets'] = array( 'pet_id' => array(215,133), 'pet' => array('Snake','Rabbit') ); echo '<pre>'; print_r($data); echo '</pre>'; ?>
-
Not really following your current issue, but as already pointed out, you need to have session_start() before accessing/using any session info. session_start(); logMe('S1: '.$_SESSION['ReqUri']); $bf = isset($_SESSION['user']['user']); logMe('S2: '.$_SESSION['ReqUri']); if(!$bf && isset($_SESSION['user']['user'])) $_SESSION['user'] = array();
-
<form action='activate.php' method='post'> Missing that end quote after activate.php.
-
Well its set as that already just I can't get the page to get the information. That's what it seems anyway. Look at your quoting. Missing something?
-
I would say yes it is.
-
Cool Debbie. Whatever works for you. As long you can keep moving forward to finish your project then that's great. As you are qualifying the user by their ID as being the person allowed to respond via their session ID, I don't think having a message ID as a hidden field is any big deal, especially as you're already using a public GET value to pass this ID in the first place.
-
Hi Debbie, You'll probably want to add a hidden input to your form to pass the message ID (msg) that you pick up from GET when you open the message. That would also mean you need to modifying your original coding where you establish the GET ID to also except POST. Not knowing how you are currently getting the ID I will offer this. if (isset($_GET['msg'])){ $msg = $_GET['msg']; } if (isset($_POST['msg'])){ $msg = $_POST['msg']; } //You then run query with variable $msg. So in your form <input type="hidden" name="msg" value="<?php if (isset($msg)){ echo $msg;} ?>" />
-
onClick javascript in PHP string not working
Drummin replied to FloorScan's topic in PHP Coding Help
$link = array("<a href=\"http://example.com\" onClick=\"recordOutboundLink(this, 'Outbound Links', 'example.com');return false;\">click here</a>","<a href=\"http://example.com/page/\" onClick=\"recordOutboundLink(this, 'Outbound Links', 'example.com/page/');return false;\">click here</a>"); -
Not sure if this will help. <html> <body> <?php isset($_POST['dropdowns']) ? include($_POST["dropdowns"]) : ""; ?> <form action="prices.php" method="post" name="prices"> <select name="dropdowns" class="selectionbox" value="options" id="selection"> <option value="ns" selected="selected">Please Select</option> <option value="selection1.php">Selection 1</option> <option value="selection2.php">Selection 2</option> <option value="selection3.php">Selection 3</option> </select> <input type="submit" value="Submit" /> </form> </body> </html>
-
Try %20 for space. It should validate for url and give you the value "dining room" to use in your query.
-
Array with Keys and Values from mysql results
Drummin replied to bschultz's topic in PHP Coding Help
mrMarcus is correct. But as you asked about building the array with the defined keys, try it this way. <?php $sql3 = "SELECT game_id, sport, visitor, home FROM games WHERE `game_id` IN ($all_games_worked_by_this_official_this_year)"; $rs3 = mysql_query($sql3,$dbc); while ($row3 = mysql_fetch_assoc($rs3)) { $games_array[]['sport'] = $row3['sport']; $games_array[]['visitor'] = $row3['visitor']; $games_array[]['home'] = $row3['home']; } print_r($games_array); ?> The result should be primary keys (0,1,2 etc) with sub-keys. You could also use the game_id as the primary key, which might be a better option assuming they are unique. <?php $sql3 = "SELECT game_id, sport, visitor, home FROM games WHERE `game_id` IN ($all_games_worked_by_this_official_this_year)"; $rs3 = mysql_query($sql3,$dbc); while ($row3 = mysql_fetch_assoc($rs3)) { $games_array[$row3['game_id']]['sport'] = $row3['sport']; $games_array[$row3['game_id']]['visitor'] = $row3['visitor']; $games_array[$row3['game_id']]['home'] = $row3['home']; } print_r($games_array); ?> -
Hello, I would like more time to modify a post. I posted some code without tags, (my bad, sorry about that), but can't fix the issue. It would be great to have more time.
-
You probably should make sure GET isset before running query. <?php if (isset($_GET['ID'])){ $ID = mysql_real_escape_string($_GET['ID']); $sql = "SELECT * FROM articles WHERE ID = '$ID'; $res = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_assoc($res); // no need to loop since you are retrieving only one row $num_rows = mysql_num_rows($res); // check to see if any results were found, just in case someone puts an ID in the url without clicking on your link if($num_rows > 0) { echo $row['ID'].' '.$row['title'].' '.$row['intro']; } else { echo "No results found"; } } ?>
-
Could echo this way. echo "{$row['ID']} {$row['title']} {$row['intro']}";
-
Not sure if this is even close to what you're looking for. <?php $names=array( "id" => array(22,47,35), "label" => array("Sally","Jim","John"), "full_name" => array("Sally Field","Jim Beam","John Doe") ); echo '<select name="names">'; foreach($names['id'] as $key => $id){ echo "<option value=\"$id\">{$names['label'][$key]}|{$names['full_name'][$key]}</option>"; } echo '</select>'; ?>
-
Problem with < form action href ... PHP variable not working
Drummin replied to mrherman's topic in PHP Coding Help
Missing the quotes. <form action="<?php echo $link_1;?>" method="post"> -
Try adding valign to both your links and content tags. This should bring both to the top of the cell. <td valign="top"> Also, that "All" link should be the full url not just # sign. <a href="forsale.php"><b><u>All</u></b></a> Be sure to update all those top links to php extension.
-
By Golly, I think you're starting to get this! Best of luck finishing your project.
-
Your links still say "type" but you updated your code to use $_GET['housetype']. Make sure any changes you make are updated any place it is used. Also make sure you're using the php extension on those links not htm Are you really going to be making images for all properties instead of using your DB? I know this has been frustrating but querying your different fields to describe the property is a better option.
-
I believe I did these changes in the updated post above where it says: $sql= "SELECT p.id, i.images2 FROM property as p "; $sql .= "LEFT JOIN images AS i ";
-
Based on what you've said I believe this is correct. <?php $host = ""; //MySQL Database user name. $login = ""; //Password for MySQL. $dbpass = ""; //MySQL Database name. $db = ""; //Make connection to DB try { $dbh = new PDO("mysql:host=mysql10.000webhost.com;dbname=$db", $login, $dbpass); } catch (PDOException $e) { print "Error!: " . $e->getMessage() . "<br/>"; die(); } //Make query. Adjust table/field names as needed. //Basic query for properies for sale $sql= "SELECT p.id, i.images2 FROM property as p "; $sql .= "LEFT JOIN images AS i "; $sql .= "ON "; $sql .= "(i.property_id = p.id) "; $sql .= "WHERE p.market_type='sale' "; //Make array of filter allowed types $types=array("detached","semi-detached","terraced","flats"); //Check for GET and if allowed type if(isset($_GET['housetype']) && in_array($_GET['housetype'], $types)){ //Add filter type to our query $sql .="AND p.housetype='{$_GET['housetype']}'"; } //Add order by $sql .=" ORDER BY p.id"; //execute query $result = $dbh->query($sql); //get result count $resultcount = $result->rowCount(); //check count for no results if ($resultcount < 1){ echo '<div class="error">Sorry, No Results Match Your Search.</div>'; } while($row = $result->fetch(PDO::FETCH_BOTH)){ echo '<div class="container" style="float:left;">'; echo '<div class="imageholder" style="float:left;">'; echo "<img class='image1' src='{$row['images2']}' alt='' /><br />"; echo '</div>'; echo '</div>'; echo '<div style="clear:both"></div>'; } ?> MAN I see you're now using a different table name. YOU'VE got to stop doing that!!! Or at least make sure you adjust code accordingly.
-
Well the only fields we're using are TABLE: property Fields: id market_type housetype TABLE: catagorys Fields: property_id image_path Do these all look correct?
-
I see you've modified the field `type`, changing it to `housetype`. Is that reflected in your DB table as well? I've seen many changes to your DB tables through this process. You should always consider how these changes will affect "work" or coding already done, for example your insert.php page. Make sure you stay consistent with table field names and page coding so if you make a change, update all pages/DB table that use this field.
-
Can you post current page code? I see a mixture of old and new on your forsale.php page.
-
Hmm, well then remove fields you don't need. I'll leave the id and image_path in this example. $sql= "SELECT p.id, c.image_path FROM property as p "; $sql .= "LEFT JOIN catagorys AS c "; $sql .= "ON "; $sql .= "(c.property_id = p.id) "; $sql .= "WHERE p.market_type='sale'";