wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
By table I am assuming you mean a MySQL table. $sql = 'SELECT id_cidade, n_anuncio FROM your_table ORDER BY id_cidade'; $result = mysql_query($sql); $prevID = 0; while($row = mysql_fetch_assoc($result)) { if($prevID != $row['id_cidade']) echo '<h1>' . $row['id_cidade'] . '</h1>'; echo $row['n_anuncio'] . '<br />'; $prevID = $row['id_cidade']; }
-
You could use regex to see if $bet only contains numbers, if ( $bet < 0 || preg_match('/[^0-9]+/', $bet) ){ $error = "One or more of your bet(s) was invalid."; error($error); }
-
$customerID = 30038; $randNumber = sprintf("%d%04d", $customerID, rand(0, 9999)); echo $randNumber;
-
You need to wrap field values within quotes $sql="SELECT domain FROM domains WHERE user='".$_SESSION['user']."'";
-
catching a proper file from remote server plz help..
wildteen88 replied to inversesoft123's topic in PHP Coding Help
The filename needs be wrapped with in quotes. -
catching a proper file from remote server plz help..
wildteen88 replied to inversesoft123's topic in PHP Coding Help
You can use, fopen and fwrite to create/write the file. -
HELP! Sessions won't work on more than 2 pages at a time!
wildteen88 replied to ShadowIce's topic in PHP Coding Help
In session sessionlesson.php and session03.php, replace this line require('sessionlesson01.php'); With just session_start(); Otherwise you're just overwriting your session variables with blank values. This is because the _POST variables will not be available on these pages, as the form is only submitted to sessionlesson02.php -
You can use array_sum, or with a foreach loop $total = 0; foreach($myArray as $value) { $total += $value; } echo $value;
-
I need a good alternative for an include statement! Suggestions?
wildteen88 replied to Flight19's topic in PHP Coding Help
The only way to include files is via the use of include or require. Why on earth do Yahoo! not allow the use of include? -
Preserving line breaks (Text Area insertation to MySQL)
wildteen88 replied to wispas's topic in PHP Coding Help
This is because web browsers ignore white space characters, such as new lines. In order for a new line to appear in a web browser you need use the <br /> tag. nl2br() converts new lines into <br /> tags. -
You can format your dates by first using the strtotime function to convert your date into a unix timestamp. You then pass the timestamp as the second parameter to the date function. This will allow you to change the appearance of your date.
-
It looks like the constant CATEGORIES_PER_ROW is controlling how many columns are being displayed. You need to find where this constant is being defined, which is probably in some configuration file. Currently CATEGORIES_PER_ROW is set to 3. You need to change it to 4 in order for the 4gth column to display.
-
PHP does not understand HTML, therefore you can't place raw HTML within the php tags. You need to use echo (or print) to send the html to the browser, as I showed you in my previous post:
-
You cant place HTML code within PHP tags. You need to use echo or print. <?php echo '<label>Tel:</label> <div>' . $row['tel'] . '</div> <label>Address:</label> <div>'. $row['address'] . '</div> <div>'. $row['county'] . $row['state'] . '</div> <div>'. ['zip'] . '</div>'; ?>
-
No adam is using HEREDOC syntax, the <<< is perfectly fine. The problem is the semi-colon ( ; ) at the end of line. Delete the semi-colon and it should fix the error
-
Yes correct. For more information regarding functions please read this
-
If you want call a PHP function when the form is submitted. Then you'll need to do something like this <?php function some_function() { echo 'form submittted'; } if(isset($_POST['submit'])) { // call function here some_function(); } ?> <fom action="" method="post"> SOME FIELD HERE <input type="submit" name="submit" value="Submit" /> </form>
-
If a form submits back to same page do you need to use $get
wildteen88 replied to deansaddigh's topic in PHP Coding Help
Leave what in? Rather than post single lines of code. Post all the code for your form. -
If a form submits back to same page do you need to use $get
wildteen88 replied to deansaddigh's topic in PHP Coding Help
No, leave it as it is. The form tag should have an action and method defined. -
Had a simple form script that suddenly stopped working
wildteen88 replied to NoWorries's topic in PHP Coding Help
The problem is your code is outdated. In order for your code to work a setting called register_globals needs to be enabled. It sounds like your webhosts has now disabled this setting (which it should be) and your code no longer works. You need to update your code so it no longer relies on this setting. Please read the manual on register_globals here. -
If a form submits back to same page do you need to use $get
wildteen88 replied to deansaddigh's topic in PHP Coding Help
This <option value="<?=$this_page.'&$year'?>" <? if($_GET{'year'}){echo 'selected';}?>><?=$year?></option> Should be <option value="<?=$year?>" <? if($_GET{'year'}){echo 'selected';}?>><?=$year?></option> -
Using the $_GET variable to view certain records
wildteen88 replied to yobo's topic in PHP Coding Help
You're getting that error because your overwriting the $guide variable while ($guide = mysql_fetch_array($guide)) That line should be while ($row = mysql_fetch_array($guide)) In your while loop use $row['guidetext'] instead of $guide['guidetext'] -
Error when insert session into table order
wildteen88 replied to thientanchuong's topic in PHP Coding Help
This line $customer_id = $_SESSION['valid_user']; Needs to be within the saveOrder() function. The problem is functions have their own variable scope, meaning they do not share variables defined outside of them. To understand this have read about variable scope -
If you want each row to have a unique identifier then you should look into using auto_increment. With an auto_increment field MySQL will assign a unique identifier for each row inserted into the table.
-
Variables are not parsed within single quotes.