Need Assignments from Señors

Hi phphelp.com

is it possible if any of the Señor php programmer give assignments for beginners just for practice purposes?

I’ve been reading alot of tutorials already, but don’t know where to start or what to do.

Thanks in advance, hope someone will volunteer :slight_smile:

Sure,

Re-write this tutorial use PDO…

http://www.phphelp.com/php_tutorial/displaying-sql-query-results.html

Once you have it working, send me or post the changes…

Take this tutorial and gather the list for the select box from a database. Post your results here or a link to your page.
http://amecms.com/article/Retaining-Drop-down-Selection-After-Form-Submit

Thank you phphelp and fastsol,

it’s really a great challenge for me, I’ll come back again if I solved this assignments.

just want to ask if there are any time limit?

cz I’m just visiting here on my free time during work :slight_smile:

I don’t see why there would be a time limit, you’re just dong this on your own free will, we don’t have any vested interest in your success. So take all the time you need and learn it well and understand how the whole process works. :smiley:

Thanks Mr.fastsol

I’ll let you know when I’m done~

might take a while though :slight_smile:

Hi,
I haven’t been active for long time, and I just got back to this site today 1/26

was really really busy with my project in our company, I have to start reviewing php from beginning since I haven’t touched/coding in php for long.

anyway, anyone want to be(volunteer) my mentor by any chance? hehehe :wink:

Hi phphelp! sorry for very late reply, I got a time now to rewrite this code to pdo, but before that I want to mention that I think there are some errors in this tutorial

[php]
function browse_users() {

}

browse_users($start_list);
[/php]

browse_users function passes some kind of arguments when called, but in the function it does not have any arguments indicated, not even default value which gave me notice on my page.

[php]
$content .= ‘

’;
[/php]
also in this line inside “function make_users_table_end()”, it does not pass any kind of $line_count value? or should I set $line_count a default value?

and make_sid() function? I searched about it but php does not have any kind of function called make_sid() is this a custom function?

but anyway here is the code I rewrote in PDO, I only changed “browse_users()” function, the other parts of the code are the same
[php]
function browse_users() {

try{
$dbh = new PDO(‘mysql:host=localhost;dbname=mydb’, ‘username’, ‘password’);
$sql = “SELECT user_id, user_pass, personal_name, family_name, user_group, email_address, DATE_FORMAT(date_created, %Y%m%d) AS member_since FROM user ORDER BY user_id DESC”;
foreach($dbh->query($sql) as $row) {

    $content .= '<tr bgcolor="'. get_alt_row_color($line_count). '">';

    $content .= '<td class="normalprint"><font

     face="Verdana,Arial,sans-serif" size="-1">' ."\n";

    $content .= '<a href="user-detail.php'. make_sid()

     .'&user_id='. $row[user_id] .'">'. $row[user_id]

      .'</a></font></td>

     <td class="normalprint"><font face="Verdana,Arial,sans-serif"

      size="-1">'. $row[personal_name] .' '. $row[family_name];

    $content .= '<td class="normalprint"><font

     face="Verdana,Arial,sans-serif" size="-1">' ."\n";

    $content .= $row[email_address];

    $content .= "</font>\n\t</td>\n";

    $content .= '<td class="normalprint"><font

     face="Verdana,Arial,sans-serif" size="-1">' ."\n";

    $content .= $user_group[$row[user_group]];

    $content .= "</font>\n\t</td>\n";

    $content .= '<td class="normalprint"><font

     face="Verdana,Arial,sans-serif" size="-1">'.

      $row[member_since] ."</td>\n";

    $content .= "</font>\n\t</td>\n</tr>\n";

    $line_count++;

}

$dbh = null;

} catch (PDOException $e) {
print "Error!: ".$e->getMEssage();
exit;
}
[/php]

:slight_smile:

I wonder when the next response will be? July 8th, 2018 ;D (Sorry I couldn’t resist ;D)

Hi fatsol! sorry for the late reply :slight_smile:

here is my modified code

[php]
$conn = new mysqli(“localhost”, “username”, “password”, “mydb”); //create db connection

$sql = "SELECT * FROM colors";				       //aquire all the colors from table
$result = $conn->query($sql);			              //get db result

$item = "green";

if($result->num_rows > 0) {
	while($row = $result->fetch_assoc()) {
		$colors[] = $row['color'];				//store all color data as array
	}
}

$conn->close();							//close db connection

echo "<form action='' method='post'>";

echo '<select name="colors">';

foreach($colors as $c) {
	$sel = '';
	$tag = 'selected="selected"';

	if(isset($_POST['colors']) && $_POST['colors'] == $c) {
		$sel = $tag;
	} elseif(!isset($_POST['colors']) && $item == $c) {
		$sel = $tag;
	}

	echo '<option value="'.$c.'" '.$sel.'>'.$c.'</option>';
}

echo '</select>';

echo '<input type="submit" name="submit" value="submit">';
echo "</form>";

[/php]

my table look like this
[table]
[tr]
[td]id [/td]
[td]|[/td]
[td] color[/td]
[/tr]
[tr]
[td]1[/td]
[td]|[/td]
[td]red[/td]
[/tr]
[tr]
[td]2[/td]
[td]|[/td]
[td]blue[/td]
[/tr]
[tr]
[td]3[/td]
[td]|[/td]
[td]green[/td]
[/tr]
[tr]
[td]4[/td]
[td]|[/td]
[td]orange[/td]
[/tr]
[/table]

Sponsor our Newsletter | Privacy Policy | Terms of Service